Register page not sending data to database

HotelHoster

Member
Sep 19, 2013
35
3
Hey DevBest
For a day or 2 now I have been working on a RevCMS skin getting all the styles sorted and layout done. I have got to the register page and have everything setup except for one thing, the register button doesn't send any data to the database.

I am not sure if this is a very simple thing and I just haven't seen it or it is because I actually have something wrong with some files. One thing I know it could be is that not all the files are in yet but most of the main files needed for RevCMS skin.

Please help if you can.
 

Khalil

IDK
Dec 6, 2011
1,642
786
Have you touched the register.php file? I'm suspecting you've deleted the code that submits the form. If yes, can you post your register.php? If not, can you post your users.class.php?
 

HotelHoster

Member
Sep 19, 2013
35
3
Have you touched the register.php file? I'm suspecting you've deleted the code that submits the form. If yes, can you post your register.php? If not, can you post your users.class.php?
Hello
The theme I am working on I have got from another website and i don't think it was originally for RevCMS. I have got it to load and work fine but the only things I have changed in the register is some scripts and links to stylsheets.

But here are the codes of the register (not enough space for class.users.php)


PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Step into another world... another Galaxy!</title>
    <script src="{url}/app/tpl/skins/{skin}/js/jquery-latest.js" type="text/javascript"></script>
    <script src="{url}/app/tpl/skins/{skin}/js/jquery-ui.js" type="text/javascript"></script>
    <script type="text/javascript" src="{url}/app/tpl/skins/{skin}/js/habbo.js"></script>
    <link href='http://fonts.googleapis.com/css?family=Ubuntu:400,500,700,400italic,500italic,700italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="{url}/app/tpl/skins/{skin}/css/reg-style.css" type="text/css" />
    <link rel="shortcut icon" href="{url}/favicon.ico" type="image/vnd.microsoft.icon" />

<script type="text/javascript">
var rev = "fwd";
function titlebar(val)
{
    var msg  = "Step into another world... another Galaxy!";
    var res = "";
    var speed = 100
    var pos = val;

    msg = msg;
    var le = msg.length;
    if(rev == "fwd"){
        if(pos < le){
        pos = pos+1;
        scroll = msg.substr(0,pos);
        document.title = scroll;
        timer = window.setTimeout("titlebar("+pos+")",speed);
        }
        else{
        rev = "bwd";
        timer = window.setTimeout("titlebar("+pos+")",speed);
        }
    }
    else{
        if(pos > 0){
        pos = pos-1;
        var ale = le-pos;
        scroll = msg.substr(ale,le);
        document.title = scroll;
        timer = window.setTimeout("titlebar("+pos+")",speed);
        }
        else{
        rev = "fwd";
        timer = window.setTimeout("titlebar("+pos+")",speed);
        }   
    }
}

titlebar(0);
</script>
<script type="text/javascript">
$(document).ready(function(){
    $("#top, #bottom").delay(500).animate({"height":"75px"}, 1500);
    $("a.logo").delay(500).addClass('finish',1500);
    $("div.inner, div#middle").delay(1250).fadeIn(500);
    $(".plane").animate({"top":"100%","left":"100%"}, 20000);
    $(".welcome-image").delay(1750).fadeIn(500);

        if(window.location.hash == "#register"){
        loadRegister();
    }

    $('#submit_login').click(function(event){
        event.preventDefault();
        loginManager.login();
    });   
   
    $('#submit_signup').click(function(event){
        event.preventDefault();
        registerManager.register();
    });   
       
    $(".registerbutton").click(function(){
        loadRegister();
    });
    $(".cancel").click(function(){
        loadLogin();
    });
});
$(document).on('mouseenter','.error-container',function(){
    $(this).hide('drop',250);
});
$(window).on('hashchange',function(){
    if(window.location.hash == "#register"){
        loadRegister();
    }
    else if(window.location.hash == "#login"){
        loadLogin();
    }
});
</script>
</head><body>
<div class="plane"></div>
<div class="welcome-image"></div>
<a class="logo"></a>
<div id="top" class="login">
    <div class="inner">
    </div>
</div>
<div id="middle" class="loginb">
    <div class="content-box login">
        <div class="l-content">
            <div class="side-one">
                <div class="padding">
                    <h1 style="margin-top:13px;">Login</h1>
                    <form><div class="input-area login">
                        <input type="text" class="text" name="username" id="username" placeholder="Email or Username" maxlength="32"/>
                        <input type="password" class="text" name="password" id="password" placeholder="Password" maxlength="32"/>
                        <div id="error_name" class="errors error-bottom"></div>
                    </div></form>
                    <a id="submit_login" class="loginsubmit submit-button button-link button-content" style="display:block;">Login ></a>
                </div>
                <div class="padding">
                    <div class="tip" style="margin-top:25px;">
                        <h3>Did you know?</h3>
                        <p>
                            When logging in with your Email Address, you go directly to <i>My Avatars</i>!
                        </p>
                    </div>
                </div>
                <div class="big_buttons">
                    <a class="cancel blue" href="{url}/account/password.php">Forgot Password?</a>
                </div>
            </div>
            <div class="side-two">
                <h1>Are you new here?</h1>
                <p>
                    A warm welcome from the community <BR>of Galaxy Hotel!
                    <BR><BR>Sign up today and experience a<BR>completely new Galaxy!
                    <BR><BR><b>There are currently 6 Users online!</b>
                </p>
                <a class="registerbutton" href="#register"><div class="register">
                    <span class="top">Join now</span>
                    <span class="bottom">for free</span>
                </div></a>
            </div>
        </div>
        <div class="r-content">
            <div class="padding">
                <div class="side-one">
                    <h1>Email Address</h1>
                    <h2>This will be used to login to your account</h2>
                        <div class="input-area">
                        <div id="error_email" class="errors error-top"></div>
                        <input id="id_email" type="text" class="text large_box" maxlength="50" />
                        </div>
                    <h1>Date of Birth</h1>
                    <h2>We want to wish you a Happy Birthday!</h2>
                    <div class="input-area">
                        <select id="id_dob_day" class="dateselector" placeholder=""><option value="">Day</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select>
                       
                        <select id="id_dob_month" class="dateselector" placeholder=""><option value="">Month</option><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select>

                        <select id="id_dob_year" class="dateselector" placeholder=""><option value="">Year</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option><option value="1939">1939</option><option value="1938">1938</option><option value="1937">1937</option><option value="1936">1936</option><option value="1935">1935</option><option value="1934">1934</option><option value="1933">1933</option><option value="1932">1932</option><option value="1931">1931</option><option value="1930">1930</option><option value="1929">1929</option><option value="1928">1928</option><option value="1927">1927</option><option value="1926">1926</option><option value="1925">1925</option><option value="1924">1924</option><option value="1923">1923</option><option value="1922">1922</option><option value="1921">1921</option><option value="1920">1920</option><option value="1919">1919</option><option value="1918">1918</option><option value="1917">1917</option><option value="1916">1916</option><option value="1915">1915</option><option value="1914">1914</option><option value="1913">1913</option><option value="1912">1912</option><option value="1911">1911</option><option value="1910">1910</option><option value="1909">1909</option><option value="1908">1908</option><option value="1907">1907</option><option value="1906">1906</option><option value="1905">1905</option><option value="1904">1904</option><option value="1903">1903</option><option value="1902">1902</option><option value="1901">1901</option><option value="1900">1900</option></select>
                        <div id="error_birthday" class="errors error-top"></div>
                    </div>
                    <input type="hidden" name="birthday" id="id_dob" />
                    <h1>Password</h1>
                    <h2>Your password must be greater than 6 characters</h2>
                        <div class="input-area">
                        <input id="id_password" type="password" class="text large_box" placeholder="Password"/>
                        <input id="id_password_confirm" type="password" class="text large_box" placeholder="Confirm Password"/>
                        <div id="error_password" class="errors error-bottom"></div>
                        </div>
                    <h1>Referrals</h1>
                    <h2>If you were referred by a user, enter their username</h2>
                    <div class="input-area">
                        <input id="id_referrals" type="text" class="text large_box" value="" maxlength="32" />
                        <div id="error_referrals" class="errors error-bottom"></div>
                    </div>
                </div>
                <div class="side-two">
                    <h1>Gender</h1>
                    <h2>You may change your look after logging in</h2>
                    <input id="male" class="id_gender" type="radio" name="gender" value="m" checked="checked">
                    <label class="gender male" for="male"><span class="img"></span></label>
                    <input id="female" class="id_gender" type="radio" name="gender" value="f">
                    <label class="gender female" for="female"><span class="img"></span></label>
                    <h1>User Details</h1>
                    <h2>Your username must be between 3 - 32 characters</h2>
                    <div class="input-area">
                        <input id="id_username" type="text" class="text large_box" placeholder="Enter your desired username" maxlength="32" />
                        <div id="error_username" class="errors error-bottom"></div>
                    </div>
                    <div class="input-area">
                        <input id="id_realname" type="text" class="text large_box" placeholder="Enter your real name (optional)" maxlength="50" />
                        <div id="error_realname" class="errors error-bottom"></div>
                    </div>
                    <h1>Captcha</h1>
                    <div class="input-area">
                        <center><div id="captcha-container">
                              <script type="text/javascript"
                                 src="http://www.google.com/recaptcha/api/challenge?k=6Le-aQoAAAAAABnHRzXH_W-9-vx4B8oSP3_L5tb0">
                              </script>
                              <noscript>
                                 <iframe src="http://www.google.com/recaptcha/api/noscript?k=6Le-aQoAAAAAABnHRzXH_W-9-vx4B8oSP3_L5tb0" height="300" width="500" frameborder="0"></iframe><br>
                                 <textarea name="recaptcha_challenge_field" id="recaptcha_challenge_field" rows="3" cols="40"></textarea>
                                 <input type="hidden" name="recaptcha_response_field" id="recaptcha_response_field" value="manual_challenge">
                              </noscript>
                        </div></center>
                        <div id="error_captcha" class="errors error-bottom"></div>
                    </div>
                    <div class="input-area">
                        <div id="error_ip" class="errors error-bottom"></div>
                    </div>
                    <div id="errors" class="errors"></div>
                </div>
            </div>
            <div class="big_buttons">
                <a class="cancel blue" href="#login">Back to Login</a>
                <a id="submit_signup" class="button-link pink">Complete Registration!</a>
            </div>
        </div>
    </div>
</div>
<div id="bottom" class="login">
    <div class="inner">
        &copy; 2014 - Galaxy Hotel. All rights reserved to their respective owner(s). <BR><i>This website is neither owned nor operated by Sulake Corporation Oy.</i>
    </div>
</div>
</body></html>
 

HotelHoster

Member
Sep 19, 2013
35
3
(not enough space for class.users.php)
Here is the class.users.php
PHP:
<?php

namespace Revolution;
if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }
class users implements iUsers
{
  
    /*-------------------------------Authenticate-------------------------------------*/
  
    final public function isLogged()
    {
        if(isset($_SESSION['user']['id']))
        {
            return true;
        }
      
        return false;
    }
  
    /*-------------------------------Checking of submitted data-------------------------------------*/
  
    final public function validName($username)   
    {
        if(strlen($username) <= 25 && ctype_alnum($username))       
         {           
             return true;       
         }                
       
         return false;   
    }        
       
    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 validSecKey($seckey)
    {
        if(is_numeric($seckey) && strlen($seckey) == 4)
        {
            return true;
        }
      
        return false;
    }
  
    final public function nameTaken($username)   
    {       
         global $engine;       
       
        if($engine->num_rows("SELECT * FROM users WHERE username = '" . $username . "' LIMIT 1") > 0)
        {
            return true;
        }   
      
        return false;
    }
  
    final public function emailTaken($email)
    {
        global $engine;
      
        if($engine->num_rows("SELECT * FROM users WHERE mail = '" . $email . "' LIMIT 1") > 0)
        {
            return true;
        }
      
        return false;
    }
      
    final public function userValidation($username, $password)
    {       
        global $engine;
        if($engine->num_rows("SELECT * FROM users WHERE username = '" . $username . "' AND password = '" . $password . "' LIMIT 1") > 0)
        {
            return true;
        }   
       
        return false;
    }        
  
    /*-------------------------------Stuff related to bans-------------------------------------*/
  
    final public function isBanned($value)
    {
        global $engine;
        
        if ($engine->num_rows("SELECT * FROM bans WHERE value = '" . $value . "' AND expire >= '" . time() . "' ") > 0)
        {
            return true;
        }

        return false;
    }
  
    final public function getReason($value)
    {
        global $engine;
        return $engine->result("SELECT reason FROM bans WHERE value = '" . $value . "' LIMIT 1");
    }
  
    final public function hasClones($ip)
    {
        global $engine;
        if($engine->num_rows("SELECT * FROM users WHERE ip_reg = '" . $_SERVER['REMOTE_ADDR'] . "'") == 5)
        {
            return true;
        }
      
        return false;
    }
  
    /*-------------------------------Login or Register user-------------------------------------*/
  
    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(isset($template->form->reg_seckey))
                                    {
                                        if($this->validSecKey($template->form->reg_seckey))
                                        {
                                            //Continue
                                        }
                                        else
                                        {
                                            $template->form->error = 'Secret key must only have 4 numbers';
                                            return;
                                        }
                                    }
                                    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, $core->hashed($template->form->reg_key));
                          
                                            $this->turnOn($template->form->reg_username);
                                  
                                            header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
                                            exit;
                                        }
                                        else
                                        {
                                            $template->form->error = 'Sorry, but you cannot register twice';
                                        }
                                    }
                                    else
                                    {
                                        $template->form->error = 'Sorry, it appears you are IP banned. ';
                                        $template->form->error .= 'Reason: ' . $this->getReason($_SERVER['REMOTE_ADDR']);
                                        return;
                                    }
                                }
                                else  
                                {
                                    $template->form->error = 'Password does not match repeated password';
                                    return;
                                }

                            }
                            else
                            {
                                $template->form->error = 'Password must have more than 6 characters';
                                return;
                            }
                        }
                        else
                        {
                            $template->form->error = 'Email: <b>' . $template->form->reg_email . '</b> is already registered';
                            return;
                        }
                    }
                    else
                    {
                        $template->form->error = 'Email is not valid';
                        return;
                    }
                }
                else
                {
                    $template->form->error = 'Username is already registered';
                    return;
                }
            }
            else
            {
                $template->form->error = 'Username is invalid';
                return;
            }
        }
    }  
  
    final public function login()
    {
        global $template, $_CONFIG, $core;
      
        if(isset($_POST['login']))
        {
            $template->form->setData();
            unset($template->form->error);
          
            if($this->nameTaken($template->form->log_username))
            {
                if($this->isBanned($_SERVER['REMOTE_ADDR']) == false)
    {
        if($this->isBanned($template->form->log_username) == 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_last', $_SERVER['REMOTE_ADDR']);
                $template->form->unsetData();
                header('Location: ' . $_CONFIG['hotel']['url'] . '/me');
                exit;
            }
            else
            {
                $template->form->error = 'Details do not match';
                return;
            }
        }
        else
        {
            $template->form->error = 'Sorry, it appears this user is banned. ';
            $template->form->error .= 'Reason: ' . $this->getReason($template->form->log_username);
            return;
        }
    }
    else
    {
        $template->form->error = 'Sorry, it appears this IP is banned. ';
        $template->form->error .= 'Reason: ' . $this->getReason($_SERVER['REMOTE_ADDR']);
        return;
    }
            }
            else
            {
                $template->form->error = 'Username does not exist';
                return;
            }
        }
    }
  
    final public function loginHK()
    {
        global $template, $_CONFIG, $core;
      
        if(isset($_POST['login']))
        {  
            $template->form->setData();
            unset($template->form->error);
          
            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')) >= 9)
                        {
                            $_SESSION["in_hk"] = true;
                            header("Location:".$_CONFIG['hotel']['url']."/ase/dash");
                            exit;
                        }
                        else
                        {
                            $template->form->error = 'Incorrect access level.';
                            return;
                        }
                    }
                    else
                    {
                        $template->form->error = 'Incorrect password.';
                        return;
                    }      
                }
                else
                {
                    $template->form->error = 'User does not exist.';
                    return;
                }
            }
  
            $template->form->unsetData();
        }
    }  
  
    final public function help()
    {
        global $template, $_CONFIG;
        $template->form->setData();
      
        if(isset($template->form->help))
        {
            $to = $_CONFIG['hotel']['email'];
             $subject = "Help from RevCMS user - " . $this->getInfo($_SESSION['user']['id'], 'username');
             $body = $template->form->question;
               
             if (mail($to, $subject, $body))
             {
                 $template->form->error = 'Message successfully sent! We will answer you shortly!';
             }
             else
             {
                   $template->form->error = 'Message delivery failed.';
             }
        }
    }

    /*-------------------------------Account settings-------------------------------------*/
  
    final public function updateAccount()
    {
        global $template, $_CONFIG, $core, $engine;

        if(isset($_POST['account']))
        {

                if(isset($_POST['acc_frndreq']) && strlen($_POST['acc_frndreq']) < 2 && $_POST['acc_frndreq'] != $this->getInfo($_SESSION['user']['id'], 'block_newfriends'))
            {
                $this->updateUser($_SESSION['user']['id'], 'block_newfriends', $engine->secure($_POST['acc_frndreq']));
                header('Location: '.$_CONFIG['hotel']['url'].'/account');
                exit;
            }
            else
            {
                $template->form->error = 'Setting is invalid.';
            }

    


                if(isset($_POST['acc_trade']) && strlen($_POST['acc_trade']) < 2 && $_POST['acc_trade'] != $this->getInfo($_SESSION['user']['id'], 'accept_trading'))
            {
                $this->updateUser($_SESSION['user']['id'], 'accept_trading', $engine->secure($_POST['acc_trade']));
                header('Location: '.$_CONFIG['hotel']['url'].'/account');
                exit;
            }
            else
            {
                $template->form->error = 'Setting is invalid.';
            }


            if(isset($_POST['acc_online']) && strlen($_POST['acc_online']) < 2 && $_POST['acc_online'] != $this->getInfo($_SESSION['user']['id'], 'hide_online'))
            {
                $this->updateUser($_SESSION['user']['id'], 'hide_online', $engine->secure($_POST['acc_online']));
                header('Location: '.$_CONFIG['hotel']['url'].'/account');
                exit;
            }
            else
            {
                $template->form->error = 'Setting is invalid.';
            }

            if(isset($_POST['acc_follow']) && strlen($_POST['acc_follow']) < 2 && $_POST['acc_follow'] != $this->getInfo($_SESSION['user']['id'], 'hide_inroom'))
            {
                $this->updateUser($_SESSION['user']['id'], 'hide_inroom', $engine->secure($_POST['acc_follow']));
                header('Location: '.$_CONFIG['hotel']['url'].'/account');
                exit;
            }
            else
            {
                $template->form->error = 'Setting is invalid.';

            }



            if(isset($_POST['acc_motto']) && strlen($_POST['acc_motto']) < 30 && $_POST['acc_motto'] != $this->getInfo($_SESSION['user']['id'], 'motto'))
            {
                $this->updateUser($_SESSION['user']['id'], 'motto', $engine->secure($_POST['acc_motto']));
                header('Location: '.$_CONFIG['hotel']['url'].'/account');
                exit;
            }
            else
            {
                $template->form->error = 'Motto is invalid.';
            }

            if(isset($_POST['acc_email']) && $_POST['acc_email'] != $this->getInfo($_SESSION['user']['id'], 'mail'))
            {
                if($this->validEmail($_POST['acc_email']))
                {
                    $this->updateUser($_SESSION['user']['id'], 'mail', $engine->secure($_POST['acc_email']));
                    header('Location: '.$_CONFIG['hotel']['url'].'/account');
                    exit;
                }
                else
                {
                    $template->form->error = 'Email is not valid';
                    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']));
                        header('Location: '.$_CONFIG['hotel']['url'].'/me');
                        exit;
                    }
                    else
                    {
                        $template->form->error = 'New password is too short';
                        return;
                    }
                }
                else
                {
                    $template->form->error = 'Current password is wrong';
                    return;
                }
            }
        }
    }


    final public function turnOn($k)
    {
        $j = $this->getID($k);
        $this->createSSO($j);
        $_SESSION['user']['id'] = $j;
        $this->cacheUser($j);
        unset($j);
    }  
    /*-------------------------------Loggin forgotten-------------------------------------*/   
  
    final public function forgotten()
    {
        global $template, $_CONFIG, $core;
      
        if(isset($_POST['forgot']))
        {
      
            $template->form->setData();
            unset($template->form->error);
          
            if($this->nameTaken($template->form->for_username))
            {
                if(strlen($template->form->for_password) > 6)
                {
                    if($this->getInfo($this->getID($template->form->for_username), 'seckey') == $core->hashed($template->form->for_key))
                    {
                        $this->updateUser($this->getID($template->form->for_username), 'password', $core->hashed($template->form->for_password));
                        $template->form->error = 'Account recovered! Go <b><a href="index">here</a></b> to login!';
                        return;
                    }
                    else
                    {
                        $template->form->error = 'Secret key is incorrect';
                        return;
                    }
                }
                else
                {
                    $template->form->error = 'Password must have more than 6 characters.';
                    return;
                }
            }
            else
            {
                $template->form->error = 'Username does not exist';
                return;
            }
        }
    }
  
    /*-------------------------------Create SSO auth_ticket-------------------------------------*/
  
    final public function createSSO($k)   
    {        
        $sessionKey = 'RevCMS-'.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);
    }

Need to cut this into 2 parts as still to big :/
 

HotelHoster

Member
Sep 19, 2013
35
3
Ok this should be all the code needed at this point

PHP:
/*-------------------------------Adding/Updating/Deleting users-------------------------------------*/
 
    final public function addUser($username, $password, $email, $motto, $credits, $pixels, $rank, $figure, $gender, $seckey)  
    {      
        global $engine;                                 
        $sessionKey = 'RevCMS-'.rand(9,999).'/'.substr(sha1(time()).'/'.rand(9,9999999).'/'.rand(9,9999999).'/'.rand(9,9999999),0,33);
        $engine->query("INSERT INTO users (username, password, mail, motto, credits, activity_points, rank, look, gender, seckey, ip_last, ip_reg, account_created, last_online, auth_ticket) VALUES('" . $username . "', '" . $password . "', '" . $email . "', '" . $motto . "', '" . $credits . "', '" . $pixels . "', '" . $rank . "', '" . $figure . "', '" . $gender . "', '" . $seckey . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . time() . "', '" . time() . "', '" . $sessionKey . "')");   
        unset($sessionKey); 
                   
    }               
      
    final public function deleteUser($k)  
    {      
        global $engine;               
         $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 updateUser($k, $key, $value)  
    {      
         global $engine;               
         $engine->query("UPDATE users SET " . $key . " = '" . $engine->secure($value) . "' WHERE id = '" . $k . "' LIMIT 1");
         $_SESSION['user'][$key] = $engine->secure($value);     
    }
 
    /*-------------------------------Handling user information-------------------------------------*/   
 
    final public function cacheUser($k)
    {
        global $engine;           
        $userInfo = $engine->fetch_assoc("SELECT username, rank, motto, mail, credits, activity_points, look, auth_ticket, ip_last FROM 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 getInfo($k, $key)
    {
        global $engine;
        if(!isset($_SESSION['user'][$key]))
        {
            $value = $engine->result("SELECT $key FROM users WHERE id = '" . $engine->secure($k) . "' LIMIT 1");
            if($value != null)
            {         
                $this->setInfo($key, $value);
            }
        }
         
        return $_SESSION['user'][$key];
    }
 
 
 
    /*-------------------------------Get user ID or Username-------------------------------------*/
 
    final public function getID($k)  
    {      
        global $engine;      
        return $engine->result("SELECT id FROM users WHERE username = '" . $engine->secure($k) . "' LIMIT 1");  
    }      
 
    final public function getUsername($k)
    {
        global $engine;
        return $this->getInfo($_SESSION['user']['id'], 'username');
    }
 
}
?>
 

HotelHoster

Member
Sep 19, 2013
35
3
So you did delete the code that submits the form..

Try this
Still doesn't add anything to the database and the captcha code that was on the register page has messed up aswell now. But all im really bothered about at the moment is getting the information to the DB
 

Users who are viewing this thread

Top