Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Revolution;
- if (!defined('IN_INDEX')) {
- die('Sorry, you cannot access this file.');
- }
- class users implements iUsers
- {
- /*-------------------------------Authenticate-------------------------------------*/
- final public function isLogged()
- {
- return isset($_SESSION['user']['id']);
- }
- /*-------------------------------Checking of submitted data-------------------------------------*/
- final public function register()
- {
- global $core, $template, $_CONFIG;
- if (isset($_POST['register'])) {
- unset($template->form->error);
- $template->form->setData();
- if ($this->validName($template->form->reg_username)) {
- if (!$this->nameTaken($template->form->reg_username)) {
- if ($this->validEmail($template->form->reg_email)) {
- if (!$this->emailTaken($template->form->reg_email)) {
- if (strlen($template->form->reg_password) > 6) {
- if ($template->form->reg_password == $template->form->reg_rep_password) {
- if ($this->isBanned($_SERVER['REMOTE_ADDR']) == false) {
- if (!$this->hasClones($_SERVER['REMOTE_ADDR'])) {
- if (!isset($template->form->reg_gender)) {
- $template->form->reg_gender = 'M';
- }
- if (!isset($template->form->reg_figure)) {
- $template->form->reg_figure = $_CONFIG['hotel']['figure'];
- }
- $this->addUser($template->form->reg_username, $core->hashed($template->form->reg_password), $template->form->reg_email, $_CONFIG['hotel']['motto'], $_CONFIG['hotel']['credits'], $_CONFIG['hotel']['pixels'], 1, $template->form->reg_figure, $template->form->reg_gender);
- $this->turnOn($template->form->reg_username);
- header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
- exit;
- } else {
- $template->form->error = 'Desculpe, mas você não pode registrar mais de três vezes!';
- }
- } else {
- $template->form->error = 'Desculpe, parece que você está Banido por IP.<br />';
- $template->form->error .= 'Razão: ' . $this->getReason($_SERVER['REMOTE_ADDR']);
- return;
- }
- } else {
- $template->form->error = 'Senha não corresponde a senha repetida!';
- return;
- }
- } else {
- $template->form->error = 'A senha deve ter mais de 6 caracteres!';
- return;
- }
- } else {
- $template->form->error = 'Email: <b>' . $template->form->reg_email . '</b> já está registrado';
- return;
- }
- } else {
- $template->form->error = 'E-mail não é válido';
- return;
- }
- } else {
- $template->form->error = 'Nome de usuário já está registrado';
- return;
- }
- } else {
- $template->form->error = 'Nome de usuário Inválido';
- return;
- }
- }
- }
- final public function validName($username)
- {
- return strlen($username) <= 25 && ctype_alnum($username);
- }
- final public function nameTaken($username)
- {
- global $engine, $tables;
- return ($engine->num_rows("SELECT NULL FROM " . $tables['table_users'] . " WHERE username = '" . $username . "' LIMIT 1") > 0);
- }
- final public function validEmail($email)
- {
- return preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $email);
- }
- final public function emailTaken($email)
- {
- global $engine;
- return $engine->num_rows("SELECT NULL FROM users WHERE mail = '" . $email . "' LIMIT 1") > 0;
- }
- /*-------------------------------Stuff related to bans-------------------------------------*/
- final public function isBanned($value)
- {
- global $engine, $tables;
- if (($engine->num_rows("SELECT NULL FROM " . $tables['table_bans'] . " WHERE value = '" . $value . "' LIMIT 1") > 0) == 0) {
- return false;
- }
- return true;
- }
- final public function GetIp()
- {
- $client = @$_SERVER['HTTP_CLIENT_IP'];
- $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
- $remote = $_SERVER['REMOTE_ADDR'];
- if (filter_var($client, FILTER_VALIDATE_IP)) {
- $ip = $client;
- } elseif (filter_var($forward, FILTER_VALIDATE_IP)) {
- $ip = $forward;
- } else {
- $ip = $remote;
- }
- return $ip;
- }
- final public function hasClones($ip)
- {
- global $engine, $tables;
- if ($ip == null) {
- $ip = $this->GetIp();
- }
- if ($engine->num_rows("SELECT NULL FROM " . $tables['table_users'] . " WHERE ip_register = '" . $ip . "'") == 300) {
- return true;
- }
- return false;
- }
- final public function addUser($username, $password, $email, $motto, $credits, $pixels, $rank, $figure, $gender)
- {
- global $engine, $tables, $users;
- $engine->query("INSERT INTO users (username, password, mail, motto, credits, " . $tables['rank_pixels'] . ", rank, look, gender, ip_current, ip_register, account_created, last_online) VALUES('" . $username . "', '" . $password . "', '" . $email . "', '" . $motto . "', '" . $credits . "', '" . $pixels . "', '" . $rank . "', '" . $figure . "', '" . $gender . "', '" . $users->GetIp() . "', '" . $users->GetIp() . "', '" . time() . "', '" . time() . "')");
- unset($sessionKey);
- }
- /*-------------------------------Login or Register user-------------------------------------*/
- final public function turnOn($k)
- {
- $j = $this->getID($k);
- $this->createSSO($j);
- $_SESSION['user']['id'] = $j;
- $this->cacheUser($j);
- unset($j);
- }
- final public function getID($k)
- {
- global $engine, $tables;
- return $engine->mysqli_result(dbquery("SELECT id FROM " . $tables['table_users'] . " WHERE username = '" . $engine->secure($k) . "' LIMIT 1"));
- }
- final public function createSSO($k)
- {
- //SSO Fix by Koala <3
- $ssoAuth = 'SSO-' . rand(9, 999) . '/' . substr(sha1(time()) . '/' . rand(9, 9999999) . '/' . rand(9, 9999999) . '/' . rand(9, 9999999), 0, 33);
- $this->updateUser($k, 'auth_ticket', $ssoAuth);
- unset($ssoAuth);
- }
- final public function updateUser($k, $key, $value)
- {
- global $engine, $tables;
- dbquery("UPDATE " . $tables['table_users'] . " SET " . $key . " = '" . $engine->secure($value) . "' WHERE id = '" . $k . "' LIMIT 1");
- $_SESSION['user'][$key] = $engine->secure($value);
- }
- /*-------------------------------Account settings-------------------------------------*/
- final public function cacheUser($k)
- {
- global $engine, $tables;
- $userInfo = $engine->fetch_assoc("SELECT " . $tables['users_row'] . "," . $tables['rank_credits'] . "," . $tables['rank_pixels'] . "," . $tables['rank_diamonds'] . " FROM " . $tables['table_users'] . " WHERE id = '" . $k . "' LIMIT 1");
- foreach ($userInfo as $key => $value) {
- $this->setInfo($key, $value);
- }
- }
- final public function setInfo($key, $value)
- {
- global $engine;
- $_SESSION['user'][$key] = $engine->secure($value);
- }
- final public function getReason($value)
- {
- global $engine;
- return $engine->mysqli_result(dbquery("SELECT reason FROM users_bans WHERE value = '" . $value . "' LIMIT 1"));
- }
- final public function login()
- {
- global $template, $_CONFIG, $core, $users;
- if (isset($_POST['login'])) {
- $template->form->setData();
- if (isset($template->form->log_username) && $this->nameTaken($template->form->log_username)) {
- if ($this->isBanned($template->form->log_username) == false || $this->isBanned($users->GetIp()) == false) {
- if ($this->userValidation($template->form->log_username, $core->hashed($template->form->log_password))) {
- $this->turnOn($template->form->log_username);
- $this->updateUser($_SESSION['user']['id'], 'ip_current', $users->GetIp());
- $template->form->unsetData();
- header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
- exit;
- } else {
- $template->form->error = 'HUPS! Syötit väärän salasanan.';
- return;
- }
- } else {
- $template->form->error = 'Et voi kirjautua sisään, koska sinulla on porttikielto<br />';
- $template->form->error .= 'Syy: ' . $this->getReason($template->form->log_username);
- return;
- }
- } else {
- $template->form->error = 'Kirjoitathan kirjautumis tiedot pääseksesi Swiftiin.';
- return;
- }
- }
- }
- /*-------------------------------Adding/Updating/Deleting users-------------------------------------*/
- final public function userValidation($username, $password)
- {
- global $engine, $tables;
- if ($engine->num_rows("SELECT NULL FROM " . $tables['table_users'] . " WHERE username = '" . $username . "' AND password = '" . $password . "' LIMIT 1") > 0) {
- return true;
- }
- return false;
- }
- final public function loginHK()
- {
- global $template, $_CONFIG, $core;
- if (isset($_POST['login'])) {
- $template->form->setData();
- if (isset($template->form->username) && isset($template->form->password)) {
- if ($this->nameTaken($template->form->username)) {
- if ($this->userValidation($template->form->username, $core->hashed($template->form->password))) {
- if (($this->getInfo($_SESSION['user']['id'], 'rank')) >= 4) {
- $_SESSION["in_hk"] = true;
- header("Location:" . $_CONFIG['hotel']['url'] . "/ase/main");
- exit;
- } else {
- $template->form->error = 'Sinulla ei riitä oikeudet';
- return;
- }
- } else {
- $template->form->error = 'Syötit väärän salasanan.';
- return;
- }
- } else {
- $template->form->error = 'Hahmoa ei löytynyt.';
- return;
- }
- }
- $template->form->unsetData();
- }
- }
- final public function getInfo($k, $key)
- {
- global $engine, $tables;
- if (!isset($_SESSION['user'][$key])) {
- $value = $engine->mysqli_result(dbquery("SELECT $key FROM " . $tables['table_users'] . " WHERE id = '" . filter($k) . "' LIMIT 1"));
- if ($value != null) {
- $this->setInfo($key, $value);
- }
- }
- return $_SESSION['user'][$key];
- }
- final public function getCurrency($k, $key, $id)
- {
- global $engine, $tables;
- if (!isset($_SESSION['user'][$key])) {
- $value = $engine->mysqli_result(dbquery("SELECT amount FROM users_currency WHERE user_id = '" . filter($k) . "' AND type='" . filter($id) . "' LIMIT 1"));
- if ($value != null) {
- $this->setInfo($key, $value);
- }
- }
- return $_SESSION['user'][$key];
- }
- final public function getOnlineCount()
- {
- global $engine, $tables;
- return $engine->mysqli_result(dbquery("SELECT COUNT(*) as online FROM users WHERE online = '1'"));
- }
- /*-------------------------------Handling user information-------------------------------------*/
- final public function help()
- {
- global $template, $_CONFIG;
- $template->form->setData();
- if (isset($template->form->help)) {
- $to = $_CONFIG['hotel']['email'];
- $subject = "Ajuda de usuário Hebbust- " . $this->getInfo($_SESSION['user']['id'], 'username');
- $body = $template->form->question;
- if (mail($to, $subject, $body)) {
- $template->form->error = 'Mensagem enviada com sucesso! Nós vamos responder a você em breve!';
- } else {
- $template->form->error = 'A entrega da mensagem falhou.';
- }
- }
- }
- final public function updateAccount()
- {
- global $template, $core, $engine;
- if (isset($_POST['account'])) {
- if (isset($_POST['acc_motto']) && strlen($_POST['acc_motto']) < 30) {
- $this->updateUser($_SESSION['user']['id'], 'motto', $engine->secure($_POST['acc_motto']));
- } else {
- $template->form->error = 'Missão invalida.';
- }
- if (isset($_POST['acc_youtube'])) {
- if (strlen($_POST['acc_youtube']) < 50) {
- $this->updateUser($_SESSION['user']['id'], 'cms_video', $engine->secure($_POST['acc_youtube']));
- } else {
- $template->form->error = 'Vídeo muito longo.';
- }
- }
- if (isset($_POST['acc_email'])) {
- if ($this->validEmail($_POST['acc_email'])) {
- $this->updateUser($_SESSION['user']['id'], 'mail', $engine->secure($_POST['acc_email']));
- } else {
- $template->form->error = 'E-mail invalido.';
- return;
- }
- }
- if (!empty($_POST['acc_old_password']) && !empty($_POST['acc_new_password'])) {
- if ($this->userValidation($this->getInfo($_SESSION['user']['id'], 'username'), $core->hashed($_POST['acc_old_password']))) {
- if (strlen($_POST['acc_new_password']) >= 8) {
- $this->updateUser($_SESSION['user']['id'], 'password', $core->hashed($_POST['acc_new_password']));
- } else {
- $template->form->error = 'Nova senha é muito curta';
- return;
- }
- } else {
- $template->form->error = 'Senha atual está errada';
- return;
- }
- }
- }
- }
- /*-------------------------------Get user ID or Username-------------------------------------*/
- final public function deleteUser($k)
- {
- global $engine;
- // todo mutli emu
- $engine->query("DELETE FROM users WHERE id = '" . $k . "' LIMIT 1");
- # $engine->query("DELETE FROM items WHERE userid = '" . $k . "' LIMIT 1");
- # $engine->query("DELETE FROM rooms WHERE ownerid = '" . $k . "' LIMIT 1");
- }
- final public function getUsername($k)
- {
- return $this->getInfo($_SESSION['user']['id'], 'username');
- }
- }
- RAW Paste Data
- <?php
- namespace Revolution;
- if (!defined('IN_INDEX')) {
- die('Sorry, you cannot access this file.');
- }
- class users implements iUsers
- {
- /*-------------------------------Authenticate-------------------------------------*/
- final public function isLogged()
- {
- return isset($_SESSION['user']['id']);
- }
- /*-------------------------------Checking of submitted data-------------------------------------*/
- final public function register()
- {
- global $core, $template, $_CONFIG;
- if (isset($_POST['register'])) {
- unset($template->form->error);
- $template->form->setData();
- if ($this->validName($template->form->reg_username)) {
- if (!$this->nameTaken($template->form->reg_username)) {
- if ($this->validEmail($template->form->reg_email)) {
- if (!$this->emailTaken($template->form->reg_email)) {
- if (strlen($template->form->reg_password) > 6) {
- if ($template->form->reg_password == $template->form->reg_rep_password) {
- if ($this->isBanned($_SERVER['REMOTE_ADDR']) == false) {
- if (!$this->hasClones($_SERVER['REMOTE_ADDR'])) {
- if (!isset($template->form->reg_gender)) {
- $template->form->reg_gender = 'M';
- }
- if (!isset($template->form->reg_figure)) {
- $template->form->reg_figure = $_CONFIG['hotel']['figure'];
- }
- $this->addUser($template->form->reg_username, $core->hashed($template->form->reg_password), $template->form->reg_email, $_CONFIG['hotel']['motto'], $_CONFIG['hotel']['credits'], $_CONFIG['hotel']['pixels'], 1, $template->form->reg_figure, $template->form->reg_gender);
- $this->turnOn($template->form->reg_username);
- header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
- exit;
- } else {
- $template->form->error = 'Desculpe, mas você não pode registrar mais de três vezes!';
- }
- } else {
- $template->form->error = 'Desculpe, parece que você está Banido por IP.<br />';
- $template->form->error .= 'Razão: ' . $this->getReason($_SERVER['REMOTE_ADDR']);
- return;
- }
- } else {
- $template->form->error = 'Senha não corresponde a senha repetida!';
- return;
- }
- } else {
- $template->form->error = 'A senha deve ter mais de 6 caracteres!';
- return;
- }
- } else {
- $template->form->error = 'Email: <b>' . $template->form->reg_email . '</b> já está registrado';
- return;
- }
- } else {
- $template->form->error = 'E-mail não é válido';
- return;
- }
- } else {
- $template->form->error = 'Nome de usuário já está registrado';
- return;
- }
- } else {
- $template->form->error = 'Nome de usuário Inválido';
- return;
- }
- }
- }
- final public function validName($username)
- {
- return strlen($username) <= 25 && ctype_alnum($username);
- }
- final public function nameTaken($username)
- {
- global $engine, $tables;
- return ($engine->num_rows("SELECT NULL FROM " . $tables['table_users'] . " WHERE username = '" . $username . "' LIMIT 1") > 0);
- }
- final public function validEmail($email)
- {
- return preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $email);
- }
- final public function emailTaken($email)
- {
- global $engine;
- return $engine->num_rows("SELECT NULL FROM users WHERE mail = '" . $email . "' LIMIT 1") > 0;
- }
- /*-------------------------------Stuff related to bans-------------------------------------*/
- final public function isBanned($value)
- {
- global $engine, $tables;
- if (($engine->num_rows("SELECT NULL FROM " . $tables['table_bans'] . " WHERE value = '" . $value . "' LIMIT 1") > 0) == 0) {
- return false;
- }
- return true;
- }
- final public function GetIp()
- {
- $client = @$_SERVER['HTTP_CLIENT_IP'];
- $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
- $remote = $_SERVER['REMOTE_ADDR'];
- if (filter_var($client, FILTER_VALIDATE_IP)) {
- $ip = $client;
- } elseif (filter_var($forward, FILTER_VALIDATE_IP)) {
- $ip = $forward;
- } else {
- $ip = $remote;
- }
- return $ip;
- }
- final public function hasClones($ip)
- {
- global $engine, $tables;
- if ($ip == null) {
- $ip = $this->GetIp();
- }
- if ($engine->num_rows("SELECT NULL FROM " . $tables['table_users'] . " WHERE ip_register = '" . $ip . "'") == 300) {
- return true;
- }
- return false;
- }
- final public function addUser($username, $password, $email, $motto, $credits, $pixels, $rank, $figure, $gender)
- {
- global $engine, $tables, $users;
- $engine->query("INSERT INTO users (username, password, mail, motto, credits, " . $tables['rank_pixels'] . ", rank, look, gender, ip_current, ip_register, account_created, last_online) VALUES('" . $username . "', '" . $password . "', '" . $email . "', '" . $motto . "', '" . $credits . "', '" . $pixels . "', '" . $rank . "', '" . $figure . "', '" . $gender . "', '" . $users->GetIp() . "', '" . $users->GetIp() . "', '" . time() . "', '" . time() . "')");
- unset($sessionKey);
- }
- /*-------------------------------Login or Register user-------------------------------------*/
- final public function turnOn($k)
- {
- $j = $this->getID($k);
- $this->createSSO($j);
- $_SESSION['user']['id'] = $j;
- $this->cacheUser($j);
- unset($j);
- }
- final public function getID($k)
- {
- global $engine, $tables;
- return $engine->mysqli_result(dbquery("SELECT id FROM " . $tables['table_users'] . " WHERE username = '" . $engine->secure($k) . "' LIMIT 1"));
- }
- final public function createSSO($k)
- {
- $sessionKey = 'SSO-' . rand(9, 999) . '/' . substr(sha1(time()) . '/' . rand(9, 9999999) . '/' . rand(9, 9999999) . '/' . rand(9, 9999999), 0, 33);
- $this->updateUser($k, 'auth_ticket', $sessionKey);
- unset($sessionKey);
- }
- final public function updateUser($k, $key, $value)
- {
- global $engine, $tables;
- dbquery("UPDATE " . $tables['table_users'] . " SET " . $key . " = '" . $engine->secure($value) . "' WHERE id = '" . $k . "' LIMIT 1");
- $_SESSION['user'][$key] = $engine->secure($value);
- }
- /*-------------------------------Account settings-------------------------------------*/
- final public function cacheUser($k)
- {
- global $engine, $tables;
- $userInfo = $engine->fetch_assoc("SELECT " . $tables['users_row'] . "," . $tables['rank_credits'] . "," . $tables['rank_pixels'] . "," . $tables['rank_diamonds'] . " FROM " . $tables['table_users'] . " WHERE id = '" . $k . "' LIMIT 1");
- foreach ($userInfo as $key => $value) {
- $this->setInfo($key, $value);
- }
- }
- final public function setInfo($key, $value)
- {
- global $engine;
- $_SESSION['user'][$key] = $engine->secure($value);
- }
- final public function getReason($value)
- {
- global $engine;
- return $engine->mysqli_result(dbquery("SELECT reason FROM users_bans WHERE value = '" . $value . "' LIMIT 1"));
- }
- final public function login()
- {
- global $template, $_CONFIG, $core, $users;
- if (isset($_POST['login'])) {
- $template->form->setData();
- if (isset($template->form->log_username) && $this->nameTaken($template->form->log_username)) {
- if ($this->isBanned($template->form->log_username) == false || $this->isBanned($users->GetIp()) == false) {
- if ($this->userValidation($template->form->log_username, $core->hashed($template->form->log_password))) {
- $this->turnOn($template->form->log_username);
- $this->updateUser($_SESSION['user']['id'], 'ip_current', $users->GetIp());
- $template->form->unsetData();
- header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
- exit;
- } else {
- $template->form->error = 'HUPS! Syötit väärän salasanan.';
- return;
- }
- } else {
- $template->form->error = 'Et voi kirjautua sisään, koska sinulla on porttikielto<br />';
- $template->form->error .= 'Syy: ' . $this->getReason($template->form->log_username);
- return;
- }
- } else {
- $template->form->error = 'Kirjoitathan kirjautumis tiedot pääseksesi Swiftiin.';
- return;
- }
- }
- }
- /*-------------------------------Adding/Updating/Deleting users-------------------------------------*/
- final public function userValidation($username, $password)
- {
- global $engine, $tables;
- if ($engine->num_rows("SELECT NULL FROM " . $tables['table_users'] . " WHERE username = '" . $username . "' AND password = '" . $password . "' LIMIT 1") > 0) {
- return true;
- }
- return false;
- }
- final public function loginHK()
- {
- global $template, $_CONFIG, $core;
- if (isset($_POST['login'])) {
- $template->form->setData();
- if (isset($template->form->username) && isset($template->form->password)) {
- if ($this->nameTaken($template->form->username)) {
- if ($this->userValidation($template->form->username, $core->hashed($template->form->password))) {
- if (($this->getInfo($_SESSION['user']['id'], 'rank')) >= 4) {
- $_SESSION["in_hk"] = true;
- header("Location:" . $_CONFIG['hotel']['url'] . "/ase/main");
- exit;
- } else {
- $template->form->error = 'Sinulla ei riitä oikeudet';
- return;
- }
- } else {
- $template->form->error = 'Syötit väärän salasanan.';
- return;
- }
- } else {
- $template->form->error = 'Hahmoa ei löytynyt.';
- return;
- }
- }
- $template->form->unsetData();
- }
- }
- final public function getInfo($k, $key)
- {
- global $engine, $tables;
- if (!isset($_SESSION['user'][$key])) {
- $value = $engine->mysqli_result(dbquery("SELECT $key FROM " . $tables['table_users'] . " WHERE id = '" . filter($k) . "' LIMIT 1"));
- if ($value != null) {
- $this->setInfo($key, $value);
- }
- }
- return $_SESSION['user'][$key];
- }
- final public function getCurrency($k, $key, $id)
- {
- global $engine, $tables;
- if (!isset($_SESSION['user'][$key])) {
- $value = $engine->mysqli_result(dbquery("SELECT amount FROM users_currency WHERE user_id = '" . filter($k) . "' AND type='" . filter($id) . "' LIMIT 1"));
- if ($value != null) {
- $this->setInfo($key, $value);
- }
- }
- return $_SESSION['user'][$key];
- }
- final public function getOnlineCount()
- {
- global $engine, $tables;
- return $engine->mysqli_result(dbquery("SELECT COUNT(*) as online FROM users WHERE online = '1'"));
- }
- /*-------------------------------Handling user information-------------------------------------*/
- final public function help()
- {
- global $template, $_CONFIG;
- $template->form->setData();
- if (isset($template->form->help)) {
- $to = $_CONFIG['hotel']['email'];
- $subject = "Ajuda de usuário Hebbust- " . $this->getInfo($_SESSION['user']['id'], 'username');
- $body = $template->form->question;
- if (mail($to, $subject, $body)) {
- $template->form->error = 'Mensagem enviada com sucesso! Nós vamos responder a você em breve!';
- } else {
- $template->form->error = 'A entrega da mensagem falhou.';
- }
- }
- }
- final public function updateAccount()
- {
- global $template, $core, $engine;
- if (isset($_POST['account'])) {
- if (isset($_POST['acc_motto']) && strlen($_POST['acc_motto']) < 30) {
- $this->updateUser($_SESSION['user']['id'], 'motto', $engine->secure($_POST['acc_motto']));
- } else {
- $template->form->error = 'Missão invalida.';
- }
- if (isset($_POST['acc_youtube'])) {
- if (strlen($_POST['acc_youtube']) < 50) {
- $this->updateUser($_SESSION['user']['id'], 'cms_video', $engine->secure($_POST['acc_youtube']));
- } else {
- $template->form->error = 'Vídeo muito longo.';
- }
- }
- if (isset($_POST['acc_email'])) {
- if ($this->validEmail($_POST['acc_email'])) {
- $this->updateUser($_SESSION['user']['id'], 'mail', $engine->secure($_POST['acc_email']));
- } else {
- $template->form->error = 'E-mail invalido.';
- return;
- }
- }
- if (!empty($_POST['acc_old_password']) && !empty($_POST['acc_new_password'])) {
- if ($this->userValidation($this->getInfo($_SESSION['user']['id'], 'username'), $core->hashed($_POST['acc_old_password']))) {
- if (strlen($_POST['acc_new_password']) >= 8) {
- $this->updateUser($_SESSION['user']['id'], 'password', $core->hashed($_POST['acc_new_password']));
- } else {
- $template->form->error = 'Nova senha é muito curta';
- return;
- }
- } else {
- $template->form->error = 'Senha atual está errada';
- return;
- }
- }
- }
- }
- /*-------------------------------Get user ID or Username-------------------------------------*/
- final public function deleteUser($k)
- {
- global $engine;
- // todo mutli emu
- $engine->query("DELETE FROM users WHERE id = '" . $k . "' LIMIT 1");
- # $engine->query("DELETE FROM items WHERE userid = '" . $k . "' LIMIT 1");
- # $engine->query("DELETE FROM rooms WHERE ownerid = '" . $k . "' LIMIT 1");
- }
- final public function getUsername($k)
- {
- return $this->getInfo($_SESSION['user']['id'], 'username');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement