This is abit too complicated for me, but I'll certainly take a look.
This is a discussion on [PHP][DEV] Base user class within the Habbo Releases forums, part of the Habbo Hotel category; I'm currently developing a Habbo CMS. (no promising that it will be released). I have just this second finished creating ...

I'm currently developing a Habbo CMS. (no promising that it will be released).
I have just this second finished creating the user class; it has logging in and sessions completely finished.. I would love for some feedback on how I could improve..
FYI, this is complete with user banning etc.PHP Code:
<?php
class Users
{
public $loggedIn = false,
$id = 0,
$userName = 'Guest',
$data = '',
$iCore;
public function Users( Core $core )
{
$this->iCore = $core;
$this->searchForSessions();
}
protected function searchForSessions()
{
global $core;
$x = array('_userName', '_passWord', '_cacheData');
$y = true;
$z = md5( db::$prefix );
foreach( $x as $q )
{
if( empty( $_SESSION[ $z . $q ] ) )
{
$y = false;
break;
}
}
if( !$y )
{
return false;
}
$this->loggedIn = (bool)
$this->iCore->db()
->newQuery()
->Query("SELECT null FROM users WHERE username = ? AND password = ? LIMIT 1;")
->bind('ss', $_SESSION[ $z . $x[ 0 ] ], $_SESSION[ $z . $x[ 1 ] ] )
->count() > 0 ? true : false;
$this->data = $_SESSION[ $z . '_cacheData' ];
return $this->loggedIn;
}
public function login( $u = '', $p = '' )
{
//p:r
if( !$u || !$p ) return 'All fields are required';
$fetch = $this->iCore->db()
->newQuery()
->Query("
SELECT
u.*, b.expire, b.reason
FROM
users AS u
LEFT JOIN
bans AS b
ON
( u.username = b.value OR b.value = ? ) AND ( UNIX_TIMESTAMP() - b.expire < 0 )
WHERE
u.username = ?
AND
u.password = ?
LIMIT 1;
")
->bind( 'sss', $_SERVER['REMOTE_ADDR'], $u, $p )
->fetch();
$x = md5( db::$prefix );
if( !empty( $fetch['reason'] ) || !empty( $fetch['expire'] ) )
{
//p:r
return sprintf( 'You are banned until %s because %s', date( 'd/m/Y h:i', $fetch['expire'] ), $fetch['reason'] );
}
$_SESSION[ $x . '_userName' ] = $fetch['username'];
$_SESSION[ $x . '_passWord' ] = $fetch['password'];
$_SESSION[ $x . '_cacheData' ] = $fetch;
header('Location: /');
}
}
(feel free to leech.)
This is abit too complicated for me, but I'll certainly take a look.
How exactly do you use cacheData?
Didn't know you were still working on it. ^^
I don't think anyone here could understand every line in that class, but to me it seems pretty good. No suggestions.
In the constructor you set the core class as variable and in the search session etc you call the core var from the global :P
Can you post it on pastebin? I cant scroll down with my phone :(
Posted via Mobile Device
Touche, I will change that now..
<?php class Users { public $loggedIn = false, - Pastebin.com
This is a good script. Maybe you could use cookies?
Sent from my mobile via Tapatalk.PHP Code:<?php
setcookie('username', $username, time()+60*60*24*100);
print $_COOKIE['username'];
?>
I believe this is in the wrong section, that's just me. Maybe you're just here to show off.