public function logIn($uid, $pass, $token) { if (!empty($uid)) { if (!empty($pass)) { if (!empty($token) && $token == $this->_SESS->getSess('dreaw_token')) { $this->_DB->query('SELECT id, pass, mail, last_logged, perm, verified FROM users WHERE uid = :uid LIMIT 1'); $this->_DB->bind(['uid' => $uid]); $this->_DB->execute(); $user_data = $this->_DB->fetchAll(); if (!empty($user_data)) { if ($user_data[0]['verified'] == 1) { if (password_verify($pass, $user_data[0]['pass'])) { $this->_SESS->setSess(['logged' => true, 'uid_logged' => $uid, 'mail_logged' => $user_data[0]['mail'], 'last_logged' => $user_data[0]['last_logged'], 'perm_logged' => $user_data[0]['perm']]); // update last_logged $this->_DB->query('UPDATE users SET last_logged = :last_logged WHERE id = :id'); $this->_DB->bind(['last_logged' => date('Y-m-d H:i:s'), 'id' => $user_data[0]['id']]); $this->_DB->execute(); // game to redirect $game = new DreawGame(); $games = $game->addedGames($_SESSION['uid_logged']); if (isset($games[1])) { header('Location: /app/myGames/'); exit(0); } elseif (isset($games[0])) { $url = '/app/games/' . $games[0]['code_represent']; header('Location: ' . $url . ''); exit(0); } else { header('Location: /app/gameAdd'); exit(0); } exit(0); } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } } else { $this->_SESS->setSess(['error' => 'Your account is not verified yet.']); } } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } } else { $this->_SESS->setSess(['error' => 'Validity of this page has expired. Please reload this page.']); return false; } } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } }
public function treat($parameters) { $game = new DreawGame(); $auth = new DreawAuthorize(); /* AJAX GET DEVELOPER INFO */ if (isset($_POST['action']) && $_POST['action'] == 'developer_detail') { $tp = new DreawTemplateParser('developer_detail', 'application/views/ajax/templates'); $tp->addTags(['empty' => false]); $tp->addDBCycleTags(['games' => $game->addedGames($_POST['uid'])]); $tp->parseTemplate(); die; } /* AJAX GET DEVELOPER INFO */ $tags = array('title' => 'KG-Rating | Developers', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'perm' => $_SESSION['perm_logged'], 'uid_logged' => $_SESSION['uid_logged']); $tp = new DreawTemplateParser('developers', 'application/views/'); $tp->addTags($tags); $tp->addDBCycleTags(['developers' => $auth->getDevelopers()]); $tp->parseTemplate(); }
public function treat($parameters) { $game = new DreawGame(); if (isset($parameters[2])) { // Are you realy this developer? if ($parameters[2] == $_SESSION['uid_logged']) { // calculate games $games = $game->addedGames($_SESSION['uid_logged']); if (isset($games[0])) { $count_games = count($games); } else { $count_games = '0'; } } else { header('Location: /app/'); } } else { header('Location: /app/'); } // Set new profile image if (isset($_POST['set_profile'])) { if (isset($_FILES['image_field'])) { $game->setProfileImage($_FILES['image_field']); } } // Change profile description if (isset($_POST['action']) && $_POST['action'] == 'change_description') { if (!empty($_POST['text'])) { $game->setDevDescription($_POST['text']); } $data = $game->getDevDescription(); die(json_encode($data)); } // output $tags = array('title' => 'KG-Rating | Profile', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'uid_logged' => $_SESSION['uid_logged'], 'mail_logged' => $_SESSION['mail_logged'], 'perm' => $_SESSION['perm_logged'], 'games_number' => $count_games, 'description' => $game->getDevDescription()); $tp = new DreawTemplateParser('profile', 'application/views/'); $tp->addTags($tags); $tp->parseTemplate(); }