Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Copyright (C) 2013 Finley Siebert
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- class Habbo {
- public function database($h, $u, $p, $db){
- $this->conn = new mysqli($h,$u,$p,$db); // So i don't have to use global.
- }
- public function url($url){
- $this->url = $url;
- return $this->url;
- }
- public function checkData($un, $pw) {
- $this->query = $this->conn->query("SELECT * FROM users WHERE username = '$un' AND password = '$pw'");
- if($this->query->num_rows == 1) {
- $_SESSION['id'] = $un;
- header('location: '. $this->url .'me');
- $ip = $_SERVER['REMOTE_ADDR'];
- $this->conn->query("UPDATE users SET ip_last = '$ip' WHERE username = '$un'");
- } else {
- echo "<div class='message error'>Wrong credintials</div>";
- }
- }
- public function generateTicket(){
- $this->sessionKey = 'ST-'.rand(9,999).'-'.substr(sha1(time()).'-'.rand(9,9999999).'-'.rand(9,9999999).'-'.rand(9,9999999),0,33);
- return $this->sessionKey;
- }
- public function registerUser($username, $password, $email, $ticket){
- $db_errors = array();
- $this->query = $this->conn->query("SELECT * FROM users WHERE username = '$username'");
- if($this->query->num_rows == 1){
- $db_errors[] = '<div class="error message">Username already in use</div>';
- }
- $this->check_email = $this->conn->query("SELECT * FROM users WHERE email = '$email'");
- if($this->check_mail->num_rows == 1 ){
- $db_errors[] = '<div class="error message"> Email already in use </div>';
- }
- foreach($db_errors as $db_e){
- echo '<div class="error message">'. $db_e .'</div>';
- }
- if(count($db_errors) == 0){
- $ip = $_SERVER['REMOTE_ADDR'];
- $this->conn->query("INSERT INTO users(username, password, mail, auth_ticket,look,motto,ip_reg) VALUES('$username', '$password', '$email', '$ticket', 'hr-115-42.hd-190-1.ch-215-62.lg-285-91.sh-290-62', 'Welcome to Habbo!','$ip')");
- $_SESSION['id'] = $username;
- header('location: '. $this->url .'me');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement