public function init() { if (database::getInstance()->isDown() || !property::getInstance()->get('collect_statistic')) { return; } $realip = system::getInstance()->getRealIp(); $visittime = time(); $browser = self::user_browser($_SERVER['HTTP_USER_AGENT']); $os = self::user_os($_SERVER['HTTP_USER_AGENT']); $cookie = $_COOKIE['source'] ?: ''; $userid = user::getInstance()->get('id'); if ($userid == null) { $userid = 0; } if ($cookie == null) { $settime = $visittime + 365 * 24 * 60 * 60; setcookie('source', system::getInstance()->md5random(), $settime, '/'); $cookie = ''; } $referer = $_SERVER['HTTP_REFERER'] ?: ''; $path = $_SERVER['REQUEST_URI'] ?: ''; $query = "INSERT INTO " . property::getInstance()->get('db_prefix') . "_statistic (ip, cookie, browser, os, time, referer, path, reg_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; $stmt = database::getInstance()->con()->prepare($query); $stmt->bindParam(1, $realip, \PDO::PARAM_STR); $stmt->bindParam(2, $cookie, \PDO::PARAM_STR, 32); $stmt->bindParam(3, $browser, \PDO::PARAM_STR); $stmt->bindParam(4, $os, \PDO::PARAM_STR); $stmt->bindParam(5, $visittime, \PDO::PARAM_INT); $stmt->bindParam(6, $referer, \PDO::PARAM_STR); $stmt->bindParam(7, $path, \PDO::PARAM_STR); $stmt->bindParam(8, $userid, \PDO::PARAM_INT); $stmt->execute(); }
private function init() { $db = db::getInstance(); $user = user::getInstance(); $this->userlang = $user->get_lang(); // initialisation $this->submit = isset($_POST['submit_form']); $this->userid = $this->mode == 'profile' ? intval($_SESSION['userid']) : (isset($_REQUEST['userid']) && intval($_REQUEST['userid']) ? intval($_REQUEST['userid']) : 0); // recherche dans la BDD $sql = 'SELECT * FROM users WHERE userid = ' . intval($this->userid); $result = $db->query($sql); $row = $result->fetch_assoc(); $result->free(); if (!$row) { die('Game over.'); } $this->username = $row['username']; $this->useremail = $row['useremail']; // recherche sur le formulaire if ($this->submit) { $this->username = isset($_POST['username']) ? trim($_POST['username']) : ''; $this->useremail = isset($_POST['useremail']) ? trim($_POST['useremail']) : ''; $this->password = isset($_POST['userpasswd']) ? trim($_POST['userpasswd']) : ''; $this->password_confirm = isset($_POST['password_confirm']) ? trim($_POST['password_confirm']) : ''; $this->userlang = isset($_POST['userlang']) ? trim($_POST['userlang']) : ''; } return true; }
private function init() { include './sys/load_iso.php'; $db = db::getInstance(); //Récupération des informaions de base: userid $this->user = user::getInstance(); $this->devin = $this->user->id; $this->devinName = $this->user->username; $this->lang = $_SESSION["langDevin"]; $sql = 'SELECT * FROM user_niveau WHERE userid=' . $this->devin; $result = $db->query($sql); $res = mysqli_fetch_assoc($result); $spoken_lang = explode(';', $res['spoken_lang']); $i = 0; while ($i < count($spoken_lang)) { if (strcmp($iso[$this->lang], $spoken_lang[$i]) == 0) { break; } $i++; } if ($i != count($spoken_lang)) { $lang_lvl = explode(';', $res['niveau'])[$i]; $sql = 'SELECT * FROM coeff_niveau_langue WHERE niveau_langue="' . $lang_lvl . '"'; $result = $db->query($sql); $this->lang_lvl_pts = mysqli_fetch_assoc($result)['coeff']; } else { $this->lang_lvl_pts = 1; //par défaut } $this->userlvl = userlvl::getInstance(); $this->points = $this->userlvl->get_points(); $this->time = $this->userlvl->get_time(); return true; }
public function process() { $user = user::getInstance(); $db = db::getInstance(); include './models/game.class.php'; include './models/grid.class.php'; // récupérer le gameid $this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false; if ($this->gameid === false) { trigger_error('Game not found', E_USER_ERROR); } // lecture de l'objet game $game = new game(); $game->read($this->gameid); // création d'une nouvelle grille $gridtype = GRIDTYPE_ALLWORDS; $grid = new grid(); $gridid = $grid->create($gridtype); // ajout de la grille au game $game->assign_grid($gridid); $game->start_grid($gridid); // enrichissement du retour json $res = $grid->get(); $res->gameid = $this->gameid; $res->gametype = GAMETYPE_PRACTICE_ALLWORDS; header('Content-Type: application/json'); echo json_encode($res); die; }
/** * Check if user is permament banned in database and display ban.tpl theme */ public function init() { $ip = system::getInstance()->getRealIp(); $time = time(); $userid = user::getInstance()->get('id'); if ($userid > 0) { $stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE (user_id = ? or ip = ?) AND (express > ? OR express = 0)"); $stmt->bindParam(1, $userid, \PDO::PARAM_INT); $stmt->bindParam(2, $ip, \PDO::PARAM_STR); $stmt->bindParam(3, $time, \PDO::PARAM_INT); $stmt->execute(); } else { $stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE ip = ? AND (express > ? OR express = 0)"); $stmt->bindParam(1, $ip, \PDO::PARAM_STR); $stmt->bindParam(2, $time, \PDO::PARAM_INT); $stmt->execute(); } $rowFetch = $stmt->fetch(); $count = $rowFetch[0]; if ($count > 0) { // block founded in db $content = template::getInstance()->twigRender('ban.tpl', array('local' => array('admin_email' => property::getInstance()->get('mail_from')))); template::getInstance()->justPrint($content); } }
private function init() { // récupération de l'id de l'utilisateur et de sa langue étudiée $this->user = user::getInstance(); $this->userlang = $this->user->langGame; $this->createur = $this->user->id; //récupération de la date au format jour/mois/année/heure $this->et_c_est_le_temps_qui_court = date("d/m/Y H:i"); //récupération des points druides $this->pointsDr = pointsDruid; // récupération du formulaire de création de carte $this->submit = isset($_POST['submit_form']); if ($this->submit) { $this->res['mot'] = isset($_POST['mot']) ? trim($_POST['mot']) : ''; $this->res['theme_carte'] = isset($_POST['theme_carte']) ? trim($_POST['theme_carte']) : ''; $this->res['nivcarte'] = isset($_POST['nivcarte']) ? trim($_POST['nivcarte']) : ''; $this->res['tabou1'] = isset($_POST['tabou1']) ? trim($_POST['tabou1']) : ''; $this->res['tabou2'] = isset($_POST['tabou2']) ? trim($_POST['tabou2']) : ''; $this->res['tabou3'] = isset($_POST['tabou3']) ? trim($_POST['tabou3']) : ''; $this->res['tabou4'] = isset($_POST['tabou4']) ? trim($_POST['tabou4']) : ''; $this->res['tabou5'] = isset($_POST['tabou5']) ? trim($_POST['tabou5']) : ''; $this->res['tabou6'] = isset($_POST['tabou6']) ? trim($_POST['tabou6']) : ''; } $db = db::getInstance(); //A theme object would not have been bad… notimenow $sql = 'SELECT DISTINCT `themeFR` FROM `themes` ORDER BY `themes`.`themeFR` ASC'; $db->query($sql); $this->theme_carte = array(); while ($theme = $db->fetch_object()) { array_push($this->theme_carte, $theme->themeFR); } return true; }
public function init() { $this->submit = isset($_POST['submit_form']); $this->userlvl = userlvl::getInstance(); $this->time = $this->userlvl->get_time(); //quand on a appuyé sur "valider", récupération du formulaire if ($this->submit) { $this->res['mot'] = isset($_POST['mot']) ? trim($_POST['mot']) : ''; $this->res['nivcarte'] = isset($_POST['nivcarte']) ? trim($_POST['nivcarte']) : ''; $this->res['tabou1'] = isset($_POST['tabou1']) ? trim($_POST['tabou1']) : ''; $this->res['tabou2'] = isset($_POST['tabou2']) ? trim($_POST['tabou2']) : ''; $this->res['tabou3'] = isset($_POST['tabou3']) ? trim($_POST['tabou3']) : ''; $this->res['tabou4'] = isset($_POST['tabou4']) ? trim($_POST['tabou4']) : ''; $this->res['tabou5'] = isset($_POST['tabou5']) ? trim($_POST['tabou5']) : ''; $this->et_c_est_le_temps_qui_court = date("d/m/Y H:i"); } // initialisation du booléen de codiion finale d'acceptation de la génération $this->boobool = true; // récupération des informations relatives à l'utilisateur: userid, et sa langue. $this->user = user::getInstance(); $this->oracle = $this->user->id; $this->userlang = $this->user->userlang; // la génération automatique de carte n'existe qu'en français pour l'instant if ($this->userlang !== 'fr') { array_push($this->errors, 'no_card_active'); } return true; }
private function display() { $db = db::getInstance(); $user = user::getInstance(); // refuser l'invitation $deleteid = isset($_REQUEST['deleteid']) ? intval($_REQUEST['deleteid']) : false; $delete = isset($_REQUEST['delete']) ? intval($_REQUEST['delete']) : false; if ($delete == 1) { $sql = 'DELETE FROM invitations WHERE invitid = ' . $deleteid; $db->query($sql); } // invitation reçues $awaitings = array(); $sql = 'SELECT i.*, u.username FROM invitations i, users u WHERE u.userid = i.fromuserid AND i.touserid = ' . intval($user->id); $result = $db->query($sql); while ($row = $result->fetch_assoc()) { $awaitings[] = $row; } // invitations envoyées $sents = array(); $sql = 'SELECT i.*, u.username FROM invitations i, users u WHERE u.userid = i.touserid AND i.fromuserid = ' . intval($user->id); $result = $db->query($sql); while ($row = $result->fetch_assoc()) { $sents[] = $row; } include './views/invitations.pendings.html'; return true; }
private function init() { // récup de userid $this->user = user::getInstance(); $this->druid = $this->user->id; return true; }
private function init() { //récupération de userid $this->user = user::getInstance(); $this->userid = $this->user->id; $this->userName = $this->user->username; $this->coef = $this->getCoeffScore(); return true; }
function initNotif() { //Récupération des informaions de base: userid $this->user = user::getInstance(); //connexion à la BD $this->db = db::getInstance(); $this->time = date('Y-m-d H:i:s'); return true; }
private function validate() { if (!$this->submit || $this->errors) { return false; } $user = user::getInstance(); $user->set_login($this->userid); redirect(''); }
private function insert_wordofday() { $db = db::getInstance(); $user = user::getInstance(); $sql = 'INSERT INTO wordofday (userid, wordofdayword, wordofdaydate, wordofdaylang) VALUES ( ' . intval($user->id) . ', ' . $db->escape((string) $this->random_word) . ', ' . intval($this->current_day) . ', ' . $db->escape((string) $this->userlang) . ')'; $db->query($sql); }
private function init() { //récupération des informations de base : userid $this->user = user::getInstance(); $this->diviner = $this->user->id; $this->devinName = $this->user->username; $this->userlvl = userlvl::getInstance(); $this->points = $this->userlvl->get_points(); return true; }
public function read() { $db = db::getInstance(); $user = user::getInstance(); $sql = 'SELECT * FROM wordbox ORDER BY wordboxword WHERE userid = ' . intval($user->id) . ' AND wordboxlang = ' . $db->escape((string) $this->wordboxlang); $db->query($sql); }
private function validate() { if (!$this->submit || $this->errors) { return false; } $user = user::getInstance(); $user->set_login($this->userid); $_SESSION["langDevin"] = $user->langGame; redirect(''); }
private function init() { $this->user = user::getInstance(); $this->oracle = $this->user->id; $this->userlang = $this->user->userlang; // Si l'utilisateur n'apprend pas le français, initalisation de wronglang à 1. Solution provisoire. if ($this->userlang !== 'fr') { $this->wronglang = "1"; } return true; }
private function init() { // récupération de l'id de l'utilisateur et de sa langue étudiée $this->user = user::getInstance(); $this->userlang = $this->user->userlang; $this->oracle = $this->user->id; $this->userlvl = userlvl::getInstance(); $this->time = $this->userlvl->get_time(); $this->points = $this->userlvl->get_points(); return true; }
public function start_grid($gridid) { $db = db::getInstance(); $user = user::getInstance(); $sql = 'UPDATE gamesstatus SET gridstatus = ' . intval(GRIDSTATUS_STARTED) . ' WHERE gameid = ' . intval($this->gameid) . ' AND gridid = ' . intval($gridid) . ' AND userid = ' . intval($user->id) . ' AND gridstatus = ' . intval(GRIDSTATUS_ASSIGNED); $db->query($sql); }
private function init() { //récupération des informations de bases : userid, langue et la date $this->user = user::getInstance(); $this->druid = $this->user->id; $this->userlang = $this->user->langGame; //récupération des points en fonction du niveau de jeu $this->userlvl = userlvl::getInstance(); $this->points = $this->userlvl->get_points(); $this->et_c_est_le_temps_qui_court = date("d/m/Y H:i"); return true; }
public function validate($in = false) { $user =& user::getInstance(); if ($user->isOnline()) { if ($this->editable) { $this->value = http_request::getString('userid'); } else { $this->value = $user->getId(); } } return false; }
private function init() { // récupération de userid $this->user = user::getInstance(); $this->oracle = $this->user->id; $this->userlang = $this->user->langGame; $this->userlvl = userlvl::getInstance(); $this->time = $this->userlvl->get_time(); // Ici il faudra récupérer le niveau de l'utilisateur pour n'afficher sur tel ou tel nb de mots tabous. // récupérer scoreID dans user, puis scoreglobal dans score. si score = tant, $niveau = facile, moyen ou difficile // En fonction, ne récupérer que le mot, les deux mots tabous ou les 5 mots tabous. Sinon on peut vider $res de ses mots tabous. return true; }
private function validate() { $db = db::getInstance(); $user = user::getInstance(); $this->fromuserid = intval($user->id); $this->touserid = isset($_GET['touserid']) ? intval($_GET['touserid']) : false; $this->invittime = time(); $sql = 'INSERT INTO invitations (fromuserid, touserid, invittime) VALUES (' . intval($this->fromuserid) . ' , ' . intval($this->touserid) . ', ' . intval($this->invittime) . ')'; $db->query($sql); return false; }
public function process() { $db = db::getInstance(); $user = user::getInstance(); include './models/grid.words.class.php'; $gameid = isset($_GET['gameid']) ? intval($_GET['gameid']) : false; $gridid = isset($_GET['gridid']) ? intval($_GET['gridid']) : false; $word = isset($_GET['word']) ? $_GET['word'] : ''; $wordexists = isset($_GET['wordexists']) ? intval($_GET['wordexists']) : false; $wordpoints = isset($_GET['wordpoints']) ? intval($_GET['wordpoints']) : false; $grid_words = new grid_words(); $grid_words->create($user->id, $gameid, $gridid, $word, $wordexists, $wordpoints); die; }
public function process() { $db = db::getInstance(); $user = user::getInstance(); include './models/game.class.php'; // récupérer le gameid si il existe $game = false; $this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false; if ($this->gameid !== false) { $game = new game(); if (!$game->read($this->gameid)) { $this->gameid = false; trigger_error('Game not found!', E_USER_ERROR); } if (!isset($game->userids[$user->id])) { $this->gameid = false; trigger_error('Not your game!', E_USER_ERROR); } } /*// fermer toute grille en cours pour cet utilisateur $sql = 'UPDATE gamesstatus SET gridstatus = ' . intval(GRIDSTATUS_FINISHED) . ' WHERE userid = ' . intval($user->id) . ' AND gridstatus = ' . intval(GRIDSTATUS_STARTED); $db->query($sql);*/ // déterminer le type de partie à partir du mode $gametype = false; switch ($this->mode) { case 'game.launch.practice.allwords': $gametype = GAMETYPE_PRACTICE_ALLWORDS; break; case 'game.launch.practice.longest': $gametype = GAMETYPE_PRACTICE_LONGEST; break; case 'game.launch.practice.constraints': $gametype = GAMETYPE_PRACTICE_CONSTRAINTS; break; case 'game.launch.practice.full': $gametype = GAMETYPE_PRACTICE_FULL; break; } // créer une nouvelle partie if (!$this->gameid) { $userids = array($user->id); $game = new game(); $this->gameid = $game->create($userids, $gametype, $user->get_lang()); } return $this->display(); }
public function process() { $user = user::getInstance(); include './models/wordbox.class.php'; $userids = array($user->id); if (isset($_GET["word"])) { $wordboxword = $_GET["word"]; $wordboxstatus = $_GET["status"]; $wordbox = new wordbox(); $wordbox->create($userids, $wordboxword, $wordboxstatus); } $msg = $wordbox->wordbox_added_msg; echo $msg; return true; }
function score($role) { require './sys/load_iso.php'; $db = db::getInstance(); $user = user::getInstance(); $langue = $user->langGame; if (isset($_SESSION["langDevin"]) && $_SESSION["langDevin"] != "") { $langue = $_SESSION["langDevin"]; } $roleUt = "score" . $role; $sql = 'SELECT ' . $roleUt . ' FROM `score` WHERE `userid`="' . $user->id . '" AND langue="' . $iso[$langue] . '"'; $res = $db->query($sql); $resultat = mysqli_fetch_assoc($res); return $resultat[$roleUt]; }
public function process() { $db = db::getInstance(); $user = user::getInstance(); include './models/game.class.php'; include './models/grid.class.php'; // récupérer le gameid $this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false; if ($this->gameid === false) { trigger_error('Game not found', E_USER_ERROR); } // lecture de l'objet game $game = new game(); $game->read($this->gameid); // lire les grilles terminées pour trouver le prochain type de grille $sql = 'SELECT COUNT(gridid) AS count_gridid FROM gamesstatus WHERE gameid = ' . intval($this->gameid) . ' AND userid = ' . intval($user->id) . ' AND gridstatus = ' . intval(GRIDSTATUS_FINISHED); $result = $db->query($sql); $grid_count = ($row = $result->fetch_assoc()) ? intval($row['count_gridid']) : 0; // déterminer le prochain type de grille switch ($grid_count) { case 0: $gridtype = GRIDTYPE_ALLWORDS; break; case 1: $gridtype = GRIDTYPE_LONGEST; break; case 2: $gridtype = GRIDTYPE_CONSTRAINTS; break; } // création d'une nouvelle grille $grid = new grid(); $gridid = $grid->create($gridtype); // ajout de la grille au game $game->assign_grid($gridid); $game->start_grid($gridid); $res = $grid->get(); $res->gameid = $this->gameid; $res->gametype = GAMETYPE_PRACTICE_FULL; header('Content-Type: application/json'); echo json_encode($res); die; }
private function display() { $db = db::getInstance(); $user = user::getInstance(); $data = array(); $sql = 'SELECT * FROM users ORDER BY username'; $result = $db->query($sql); while ($row = $result->fetch_assoc()) { $row['_is_online'] = $row['useronline'] >= intval(time() - user::SESSION_DURATION); $data[] = $row; } $result->free(); include './views/members.html'; return true; }
private function init() { // récupération de l'id de l'utilisateur et de sa langue à étudier $this->user = user::getInstance(); $this->userlang = $this->user->userlang; $this->oracle = $this->user->id; //récupération du l'id de la carte dans la zone de texte $this->submit = isset($_POST['submit_form']); if ($this->submit) { $this->carteId = isset($_POST['carteId']) ? trim($_POST['carteId']) : ''; } else { if (isset($_SESSION["idCard"])) { $this->carteId = isset($_SESSION['idCard']) ? trim($_SESSION['idCard']) : ''; } } return true; }