One last problem

Diddy

Member
Aug 14, 2011
98
20
So After alot of thinking and looking i manged to get ubercms working at last so many errors.

I have ran into one problem i can not fix though and thats when a user signs up and goes to the page register_submit they get this error

Code:
Warning: mysql_result(): Unable to jump to row 1 on MySQL result index 15 in C:\inetpub\wwwroot\inc\class.users.php on line 84
 
Duplicate entry '0' for key 'PRIMARY'

Anyone possibly know how to fix?

My line 84 is

Code:
$id = intval(mysql_result(dbquery("SELECT id FROM users WHERE username = '" . $username . "' ORDER BY id DESC LIMIT 1"), 0));
 

Diddy

Member
Aug 14, 2011
98
20
Register.php

Code:
<?php
/*=======================================================================
| UberWeb - Lightweight site system for Uber
| #######################################################################
| Copyright (c) 2009, Roy 'Meth0d'
| http://www.meth0d.org
| #######################################################################
| 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.
\======================================================================*/
 
require_once "global.php";
 
 
if (LOGGED_IN)
{
    header("Location: " . WWW . "/me");
    exit;
}
 
 
$tpl->SetParam('error-messages-holder', '');
$tpl->SetParam('post-name', '');
$tpl->SetParam('post-pass', '');
$tpl->SetParam('post-tos-check', '');
$tpl->SetParam('post-mail', '');
 
if (isset($_GET['doSubmit']))
{
    if (isset($_POST['checkNameOnly']) && $_POST['checkNameOnly'] == 'true')
    {
        //$name = $_POST['bean_avatarName'];
        $name = mysql_real_escape_string($_POST['bean_avatarName']);
 
        echo '                <div class="field field-habbo-name">
                  <label for="habbo-name">Username</label>
                  <input type="text" id="habbo-name" size="32" value="' . clean($name) . '" name="bean.avatarName" class="text-field" maxlength="32"/>
                <a href="#" class="new-button" id="check-name-btn"><b>Check</b><i></i></a>
              <input type="submit" name="checkNameOnly" id="check-name" value="Check"/>
                    <div id="name-suggestions">';
     
        if (!$users->IsValidName($name))
        {
            echo '<div class="taken"><p>Sorry, that name is invalid. Your name can contain lowercase, uppercase letters, and numbers.</p></div>';
        }
        else if ($users->IsNameTaken($name))
        {
            echo '<div class="taken"><p>Sorry, the name <strong>' . clean($name) . '</strong> is taken!</p></div>';
        }
        else if ($users->IsNameBlocked($name))
        {
            echo '<div class="taken"><p>Sorry, that name is reserved or disallowed.</p></div>';
        }
        else
        {
            echo '<div class="available"><p>The name <strong>' . clean($name) . '</strong> is available.</p></div>';
        }
                         
        echo '                    </div>           
                  <p class="help">Your name can contain lowercase and uppercase letters and numbers.</p>
                </div>';
     
        exit;
    }
    else if (isset($_POST['bean_avatarName']))
    {
        $registerErrors = Array();
 
        $name = mysql_real_escape_string($_POST['bean_avatarName']);
        $password = $_POST['bean_password'];
        $password2 = $_POST['bean_retypedPassword'];
        $email = mysql_real_escape_string($_POST['bean_email']);
        $dob_day = $_POST['bean_day'];
        $dob_month = $_POST['bean_month'];
        $dob_year = $_POST['bean_year'];
        //$lang = $_POST['bean_lang'];
     
        $tpl->SetParam('post-name', $name);
        $tpl->SetParam('post-pass', $password);
        $tpl->SetParam('post-mail', $email);
     
        if (strlen($name) < 1 || strlen($name) > 32)
        {
            $registerErrors[] = "Your username must be 1 - 32 characters in length.";
        }
     
        if ($users->IsNameTaken($name))
        {
            $registerErrors[] = "Sorry, that name is taken.";
        } 
        else if ($users->IsNameBlocked($name))
        {
            $registerErrors[] = "Sorry, that name is reserved or disallowed.";
        }
        else if (!$users->IsValidName($name))
        {
            $registerErrors[] = "Sorry, that name is invalid. Your name can contain lowercase, uppercase letters, and numbers.";
        }
     
        if (strlen($password) < 6)
        {
            $registerErrors[] = "Your password must be at least 6 characters long.";
        }
     
        if ($password != $password2)
        {
            $registerErrors[] = "Your passwords do not match. Please try again.";
        }
     
        if (!$users->IsValidEmail($email))
        {
            $registerErrors[] = "Invalid e-mail address.";
        }
     
        if (!is_numeric($dob_day) || !is_numeric($dob_month) || !is_numeric($dob_year) || $dob_day <= 0 || $dob_day > 31 ||
            $dob_month <= 0 || $dob_month > 12 || $dob_year < 1900 || $dob_year > 2010)
        {
            $registerErrors[] = "Please enter a valid date of birth.";
        }
     
        if (!isset($_POST['bean_tos']) || $_POST['bean_tos'] != "accept")
        {
            $registerErrors[] = "You need to accept the Rules and Terms and Conditions to create an account.";
        }
        else
        {
            $tpl->SetParam('post-tos-check', 'checked');
        }
     
        /*if (strtolower($lang) != "yes, i will speak english" && strtolower($lang) != "yes, i will speak english.")
        {
            $registerErrors[] = "You must verify you will speak English to creat an account.";
        }*/
     
     
        if (count($registerErrors) <= 0)
        {         
            // Add user
            $users->add($name, $core->uberHash($password), $email, 2, 'hd-180-1.ch-210-66.lg-270-82.sh-290-91.hr-100-', 'M');
         
            // Log user in
            $_SESSION['SHOW_WELCOME'] = true;
            $_SESSION['UBER_USER_N'] = $name;
            $_SESSION['UBER_USER_H'] = $core->uberHash($password);
         
            // Redirect user to welcome page
            header("Location: /me.php");
            exit;
        }
        else
        {
            $errResult = '<div class="error-messages-holder">
                <h3>Please fix the following problems and resubmit the form.</h3>
                <ul>';
         
            foreach ($registerErrors as $err)
            {
                $errResult .= '<li><p class="error-message">' . $err . '</p></li>';
            }
         
            $errResult .= '</ul></div>';
     
            $tpl->SetParam('error-messages-holder', $errResult);
        }
    }
}
 
$tpl->Init();
 
$tpl->AddGeneric('head-init');
$tpl->AddIncludeSet('register');
$tpl->WriteIncludeFiles();
$tpl->AddGeneric('head-bottom');
$tpl->AddGeneric('page-register');
$tpl->AddGeneric('footer');
 
$tpl->SetParam('page_title', 'Register your account!');
 
$tpl->Output();
 
?>

page-register.tpl

Code:
<style>body {    background-image: url(images/bg.png);}#phase-0-form { background: transparent url(http:///images/logo.png) no-repeat 50% 10px; padding-top: 60px }</style>
<style>
a.new-button{margin:0 0 5px 10px;display:block;float:right;height:25px;position:relative;text-decoration:none;cursor:pointer;overflow:hidden;white-space:nowrap;}
#check-name{display:none}
</style>
<script src="%www%/simpleregistration.js"></script>
<body id="">
<div id="overlay"></div>
<div id="container" class="phase-0" style="margin-top: 10px;">
    <p class="phishing-warning">Make sure the address bar begins with %www%.</p>
    <div class="register-container clearfix">
        <div class="register-header">Register at  Hotel</div>
      <div id="register-content">
   
        <div id="subheader">Fill out the form below to register here.
</div>
 
<div class="register-container-bottom-end register-content clearfix">
<div id="auth-providers" class="auth-providers">
    <ul>
        <li class="facebook">
            <a href="#" onclick="" class="fbconnect_login_button"></a>
        </li>
        <li class="twitter">
            <a href="#"></a>
<form method="post" action="" target="rpx_login">
    <input type="submit" value="twitter"/>
</form>
        </li>
        <li class="google">
            <a href="#"></a>
<form method="post" action="" target="rpx_login">
    <input type="hidden" value="https://www.google.com/accounts/o8/id" name="openid_identifier" id="openid_identifier"/>
    <input type="submit" value="google"/>
</form>
        </li>
        <li class="hyves">
            <a href="#"></a>
<form method="post" action="" target="rpx_login">
    <input type="hidden" value="http://hyves.net/" name="openid_identifier" id="openid_identifier"/>
    <input type="submit" value="hyves"/>
</form>
        </li>
        <li class="myspace">
            <a href="#"></a>
<form method="post" action="" target="rpx_login">
    <input type="submit" value="myspace"/>
</form>
        </li>
        <li class="windowslive">
            <a href="#"></a>
<form method="post" action="" target="rpx_login">
    <input type="submit" value="windowslive"/>
</form>
        </li>
        <li class="yahoo">
            <a href="#"></a>
<form method="post" action="" target="rpx_login">
    <input type="hidden" value="http://yahoo.com" name="openid_identifier" id="openid_identifier"/>
    <input type="submit" value="yahoo"/>
</form>
        </li>
  </ul>
<p>You can also use these option to create an account:</p>
<p><b>We do not <u>yet</u> offer third-party account services. We will add this functionality during the Public BETA, for now please use regular account creation.</b></p>
</div>
<div id="register-page" style="clear: left" class="phase-0 clearfix">
    <p>Welcome to </p>
    <div class="phase-0">
        <form action="/register_submit" method="post" id="phase-0-form">
         
            <div id="error-messages-container">
            %error-messages-holder%
            </div>
         
            <div id="name-field-container">
                <div class="field field-habbo-name">
                  <label for="habbo-name"><b>Name</b></label>
                  <input type="text" id="habbo-name" size="32" value="%post-name%" name="bean.avatarName" class="text-field" maxlength="32"/>
                  <a href="#" class="new-button" id="check-name-btn"><b>Check</b><i></i></a>
                  <input type="submit" name="checkNameOnly" id="check-name" value="Check"/>
                    <div id="name-suggestions">
                    </div>           
                  <p class="help">Choose a username (Usernames such as MOD-, ADM- & VIP- will be banned)</p>
                </div>
            </div>
            <div class="field field-password">
              <label for="password"><b>Password</b></label>
              <input type="password" id="password" size="35" name="bean.password" value="%post-pass%" class="password-field" maxlength="32"/>
              <p class="help">Choose a password</p>
            </div>
         
            <div class="field field-password2">
              <label for="password2"><b>Retype Password</b></label>
              <input type="password" id="password2" size="35" name="bean.retypedPassword" value="" class="password-field" maxlength="32"/>
              <p class="help">Verify your password</p>
            </div>
         
            <div class="field field-email">
              <label for="email"><b>Email</b></label>
              <input type="text" id="email" size="35" name="bean.email" value="%post-mail%" class="text-field" maxlength="48"/>
              <p class="help">Enter an email address</p>
            </div>
                     
            <div class="field field-birthday">
              <label><b>Date of Birth</b></label>
              <span id="bday-selects">
<select name="bean.day" id="bean_day" class="dateselector"><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 name="bean.month" id="bean_month" class="dateselector"><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 name="bean.year" id="bean_year" class="dateselector"><option value="">Year</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</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>              </span>
              <p class="help">Please enter your date of birth</p>           
            </div>
                     
            <div class="field field-parent-email">
              <label for="parent-email">Parent or guardian's email address</label>
              <input type="text" id="parent-email" size="35" name="bean.parentEmail" value="" class="text-field" maxlength="128"/>
              <p class="help">Because you are under 16 and in accordance with industry best practice guidelines, we require your parent or guardian's email address.</p>
            </div>
         
            <div class="field field-parent-permission">
            </div>
         
            <script>
            var RecaptchaOptions = {
              theme : 'white'
            };
            </script>
         
            <style type="text/css">
            #recaptcha_response_field
            {
                font-size: 12px !important;
                font-weight: normal !important;
            }
            </style>         
         
         
         
            <div class="field field-tos">
         
                <input id="tos" value="accept" type="checkbox" id="password" name="bean.tos" %post-tos-check%/>I accept the Terms and Conditions</a>.
         
            </div>
 
            <a href="#" class="new-button" id="next-btn"><b>Create Account</b><i></i></a>
            <input type="submit" id="next" value="Create account" /><a href="%www%/register/cancel">Cancel</a>
 
        </form>
 
    </div>
 
</div>
<script type="text/javascript">
    L10N.put("embedded_registration.errors.header", "Please fill in all the forms");
    L10N.put("register.error.password_required", "Please enter a password");
    L10N.put("register.error.retyped_password_required", "Please re enter your password");
    L10N.put("register.error.retyped_password_notsame", "Passwords don't match");
    L10N.put("register.error.password_length", "Your password is too long");
    L10N.put("register.error.password_chars", "Your password is too short");
    SimpleRegistration.initRegistrationUI("/");
</script>
 
        </div>
    </div>
    <div class="register-container-bottom"></div>
 

Diddy

Member
Aug 14, 2011
98
20
Sorry

Code:
<?php
/*=======================================================================
| UberCMS - Advanced Website and Content Management System for uberEmu
| #######################################################################
| Copyright (c) 2010, Roy 'Meth0d'
| http://www.meth0d.org
| #######################################################################
| 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.
\======================================================================*/
 
class uberUsers
{
  /**************************************************************************************************/
 
  private $userCache = Array();
 
  /**************************************************************************************************/
 
  private $blockedNames = Array('roy', 'meth0d', 'method', 'graph1x', 'graphix', 'admin', 'administrator',
    'mod', 'moderator', 'guest', 'undefined');
  private $blockedNameParts = Array('moderate', 'staff', 'manage', 'system', 'admin', 'uber');
 
  /**************************************************************************************************/
 
  public function IsValidEmail($email = '')
  {
    return preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $email);
  }
 
  public function IsValidName($nm = '')
  {
    if (preg_match('/^[a-z0-9]+$/i', $nm) && strlen($nm) >= 1 && strlen($nm) <= 32)
    {
      return true;
    }
   
    return false;
  }
 
  public function IsNameTaken($nm = '')
  {
    return ((mysql_num_rows(dbquery("SELECT null FROM users WHERE username = '" . $nm . "' LIMIT 1")) > 0) ? true : false);
  }
 
  public function IdExists($id = 0)
  {
    return ((mysql_num_rows(dbquery("SELECT null FROM users WHERE id = '" . $id . "' LIMIT 1")) > 0) ? true : false);
  }
 
  public function IsNameBlocked($nm = '')
  { 
    foreach ($this->blockedNames as $bl)
    {
      if (strtolower($nm) == strtolower($bl))
      {
        return true;
      }
    }
   
    foreach ($this->blockedNameParts as $bl)
    {
      if (strpos(strtolower($nm), strtolower($bl)) !== false)
      {
        return true;
      }
    }
   
    return false;
  } 
 
  /**************************************************************************************************/
 
  function Add($username = '', $passwordHash = '', $email = 'default@localhost', $rank = '2', $figure = '', $sex = 'M')
  {
  @mysql_query("INSERT INTO users (username,password,mail,auth_ticket,rank,look,gender,motto,credits,activity_points,last_online,account_created,ip_last,ip_reg,expert) VALUES ('" . $username . "','" . $passwordHash . "','" . $email . "','','" . $rank . "','" . $figure . "','" . $sex . "','','25000','2000','". time() ."','" . date('d-M-Y') . "', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['REMOTE_ADDR']."', '0')");   
    $id = intval(mysql_free_result(dbquery("SELECT id FROM users WHERE username = '" . $username . "' LIMIT 1")));
    dbquery("INSERT INTO user_info (user_id,bans,cautions,reg_timestamp,login_timestamp,cfhs,cfhs_abusive) VALUES ('" . $id . "','0','0','" . time(). "','" . time() . "','0','0')");
    return $id;
  }
 
  function Delete($id)
  {
    dbquery("DELETE FROM messenger_friendships WHERE user_one_id = '" . $id . "' OR user_two_id = '" . $id . "'");
    dbquery("DELETE FROM messenger_requests WHERE to_id = '" . $id . "' OR from_id = '" . $id . "'");
    dbquery("DELETE FROM users WHERE id = '" . $id . "' LIMIT 1");
    dbquery("DELETE FROM user_subscriptions WHERE user_id = '" . $id . "'");
    dbquery("DELETE FROM user_info WHERE user_id = '" . $id . "' LIMIT 1");
    dbquery("DELETE FROM user_items WHERE user_id = '" . $id . "'");
  }
 
  /**************************************************************************************************/
 
  function ValidateUser($username, $password)
  {
    return mysql_num_rows(dbquery("SELECT null FROM users WHERE username = '" . $username . "' AND password = '" . $password. "' LIMIT 1"));
  }
 
  /**************************************************************************************************/
 
  function Name2id($username = '')
  {
    return @intval(mysql_result(dbquery("SELECT id FROM users WHERE username = '" . $username . "' LIMIT 1"), 0));
  }
 
  function Id2name($id = -1)
  {
    if (isset($this->userCache[$id]['username']))
    {
      return $this->userCache[$id]['username'];
    } 
 
    $name = mysql_result(dbquery("SELECT username FROM users WHERE id = '" . $id . "' LIMIT 1"), 0);
    $this->userCache[$id]['username'] = $name;
    return $name;
  } 
 
  /**************************************************************************************************/
 
  function CacheUser($id)
  {
    $data = mysql_fetch_assoc(dbquery("SELECT * FROM users WHERE id = '" . $id . "' LIMIT 1"));
   
    foreach ($data as $key => $value)
    {
      $this->userCache[$id][$key] = $value;
    }
  }
 
  function GetUserVar($id, $var, $allowCache = true)
  {
    if ($allowCache && isset($this->userCache[$id][$var]))
    {
      if ($var == "last_online")
      {
      return "<i>Never</i>";
      }
      else
      {
      return $this->userCache[$id][$var];
      }
    }
   
    $val = @mysql_result(dbquery("SELECT " . $var . " FROM users WHERE id = '" . $id . "' LIMIT 1"), 0);
    $this->userCache[$id][$var] = $val;
    return $val;
  }
 
  // do not remove - still used in hk
  function formatUsername($id, $link = true, $styles = true)
  {
    $datas = dbquery("SELECT id,rank,username FROM users WHERE id = '" . $id . "' LIMIT 1");
   
    if (mysql_num_rows($datas) == 0)
    {
      return '<s>Unknown User</s>';
    }
   
    $data = mysql_fetch_assoc($datas);
   
    $prefix = '';
    $name = $data['username'];
    $suffix = '';
   
    if ($link)
    {
      $prefix .= '<a href="/user/' . clean($data['username']) . '">';
      $suffix .= '</a>';
    }
   
    if ($styles)
    {
      $rank = $this->getRank($id);
 
    }
   
    return clean($prefix . $name . $suffix, true);
  }
  // do not remove - still used in hk
 
  /**************************************************************************************************/
 
  function getRank($id)
  {
    if (isset($this->userCache[$id]['rank']))
    {
      return $this->userCache[$id]['rank'];
    }
 
    $rankId = @intval(mysql_result(dbquery("SELECT rank FROM users WHERE id = '" . intval($id) . "' LIMIT 1"), 0));
    $this->userCache[$id]['rank'] = $rankId;
    return $rankId;
  }
 
  function getRankVar($rankId, $var)
  {
    return mysql_result(dbquery("SELECT " . $var . " FROM ranks WHERE id = '" . intval($rankId) . "' LIMIT 1"), 0);
  }
 
  function getRankName($rankId)
  {
    return $this->getRankVar($rankId, 'name');
  }
 
  function hasFuse($id, $fuse)
  {   
    if (mysql_num_rows(dbquery("SELECT null FROM fuserights WHERE rank <= '" . $this->getRank($id) . "' AND fuse = '" . $fuse . "' LIMIT 1")) == 1)
    {
      return true;
    }
   
    return false;
  }
 
  /**************************************************************************************************/
 
  function GetFriendCount($id, $onlineOnly = false)
  {
    $i = 0;
    $q = dbquery("SELECT user_two FROM friendships WHERE user_one = '" . $id . "'");
   
    while ($friend = mysql_fetch_assoc($q))
    {
      if (!$onlineOnly)
      {
        $i++;
      }
      else
      {
        $isOnline = mysql_result(dbquery("SELECT online FROM users WHERE id = '" . $friend['user_two'] . "' LIMIT 1"), 0);
         
        if ($isOnline == "1")
        {
          $i++;
        }
      }
    }
   
    return $i;
  }
 
  /**************************************************************************************************/
 
  function CheckSSO($id)
  {
    global $core;
   
    if (strlen($this->getUserVar($id, 'auth_ticket')) <= 3)
    {
      dbquery("UPDATE users SET auth_ticket = '" . $core->generateTicket($this->getUserVar($id, 'username')) . "' WHERE id = '" . $id . "' LIMIT 1");
    }
  }
 
  /**************************************************************************************************/
 
  function getCredits($id)
  {
    return $this->getUserVar($id, 'credits');
  }
 
  function setCredits($id, $newAmount)
  {
    global $core;
 
    dbquery("UPDATE users SET credits = '" . $newAmount. "' WHERE id = '" . $id . "' LIMIT 1");
    $core->Mus('updateCredits:' . $id);
  }
 
  function giveCredits($id, $amount)
  {
    global $core;
 
    return $this->setCredits($id, ($this->getCredits($id) + $amount));
    $core->Mus('updateCredits:' . $id);
  }
 
  function takeCredits($id, $amount)
  {
    global $core;
 
    return $this->setCredits($id, ($this->getCredits($id) - $amount));
    $core->Mus('updateCredits:' . $id);
  } 
 
  function renderHabboImage($id, $size = 'b', $dir = 2, $head_dir = 3, $action = 'wlk', $gesture = 'sml')
  {
    $look = $this->getUserVar($id, 'look');
   
    return 'http://www.habbo.co.uk/habbo-imaging/avatarimage?figure=' . $look . '&size=' . $size . '&action=' . $action . ',&gesture=' . $gesture . '&direction=' . $dir . '&head_direction=' . $head_dir;
  }
 
  function getClubDays($id)
  {
    $sql = dbquery("SELECT timestamp_activated, timestamp_expire FROM user_subscriptions WHERE subscription_id = 'habbo_club' AND user_id = '" . $id . "' LIMIT 1");
   
    if (mysql_num_rows($sql) == 0)
    {
      return 0;
    }
   
    $data = mysql_fetch_assoc($sql);
    $diff = $data['timestamp_expire'] - time();
   
    if ($diff <= 0)
    {
      return 0;
    }
   
    return ceil($diff / 86400);
  }
 
  function hasClub($id)
  {
    return ($this->getClubDays($id) > 0) ? true : false;
  }
 
  /**************************************************************************************************/
 
  public static function IsUserBanned($name)
  {
    if (uberUsers::GetBan('user', $name, true) != null)
    {
      return true;
    }
   
    return false;
  }
 
  public static function IsIpBanned($ip)
  {
    if (uberUsers::GetBan('ip', $ip, true) != null)
    {
      return true;
    }
   
    return false;
  }
 
  public static function GetBan($type, $value, $mustNotBeExpired = false)
  {
    $q = "SELECT * FROM bans WHERE bantype = '" . $type . "' AND value = '" . $value . "' ";
   
    if ($mustNotBeExpired)
    {
      $q .= "AND expire > " . time() . " ";
    }
   
    $q .= "LIMIT 1";
 
    $get = dbquery($q);
   
    if (mysql_num_rows($get) > 0)
    {
      return mysql_fetch_assoc($get);
    }
 
    return null;
  } 
 
  /**************************************************************************************************/
 
  public static function GetUserTags($userId)
  {
    $tagsArray = Array();
    $data = dbquery("SELECT id,tag FROM user_tags WHERE user_id = '" . $userId . "'");
   
    while ($tag = mysql_fetch_assoc($data))
    {
      $tagsArray[$tag['id']] = $tag['tag'];
    }
   
    return $tagsArray;
  }
 
  /***************************************************************************/
  // HOMES
 
  public function EatCredits($id, $credits, $restar = true)
  {
    if($restar)
    {
      dbquery("UPDATE users SET credits = credits - ".$credits." WHERE id = '".$id."' LIMIT 1"); 
    }
    else
    {
      dbquery("UPDATE users SET credits = ".$credits." WHERE id = '".$id."' LIMIT 1");
    }
    return true; 
  }
 
  public static function haveWidget($Id, $var)
  {
    $check = mysql_num_rows(dbquery("SELECT id FROM homes_items WHERE data = '" . $var . "' AND owner_id = '" . $Id . "' LIMIT 1"));
   
    if($check > 0)
    {
      return true;
    }
    else
    {
      return false;
    }
  }
 
  public function IsUserOnline($id = USER_ID, $numbers = false)
  {
    $CheckOnline = mysql_result(dbquery("SELECT online FROM users WHERE id = '".$id."' LIMIT 1"), 0);
    if($CheckOnline == '1') {
      return true;
    } else {
      return false;
    }
  }
}
 
 
?>
 

Users who are viewing this thread

Top