Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption

Status
Not open for further replies.
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Is it possible to use the same database structure as Phoenix so we can have one single login for both an old school and a new school? :p

I'm sorry, but v5 has no website login. v5 didn't have SSO ticket login. Besides, the database would only contain unnecessary tables and rows which makes it unclean, so no, I'll won't make it compatible with Phoenix database.

@Tha

PHP:
<?php

// Include some important files
include 'cls/main.class.php';
include 'cls/database.class.php';
//include 'cls/members.class.php';
//include 'cls/habboclub.class.php';
//include 'cls/news.class.php';
//include 'cls/events.class.php';
//include 'cls/homes.class.php';

// Start the main class
Main::initialize();

Why are you including them manually? Why not autoload them? The code can be simplified like this:

PHP:
<?php
function autoload($classname) {
    require_once('cls/' . $classname . '.class.php');
}
spl_autoload_register('autoload');

Then, you create instances here in this particular file, and then include that file in every page, this way, no need to repeat instancing, etc and all classes are here. If you wish to get your code deeply reviewed by experts,

I haven't used autoload before, so that's why. But well, if the stability doesn't change I'd prefer my own code since it's easier for me at the moment :) Thanks though for the suggestion.
 
Joined
Jun 23, 2010
Messages
2,324
Reaction score
2,195
I'm sorry, but v5 has no website login. v5 didn't have SSO ticket login. Besides, the database would only contain unnecessary tables and rows which makes it unclean, so no, I'll won't make it compatible with Phoenix database.



I haven't used autoload before, so that's why. But well, if the stability doesn't change I'd prefer my own code since it's easier for me at the moment :) Thanks though for the suggestion.

autoloading in combination with namespaces is the way to go for me! In each file you get exactly to know what uses what and where it's from.

PHP:
######## somefile.php ########

<?php
 spl_autoload_extensions('.php');
    spl_autoload_register();
    
    use Templates\JPVote\Php\Controllers\IndexController;
    
    $controller = new IndexController();
$controller->Initialize();
?>

######## templates\jpvote\php\controllers\indexcontroller.php ########

<?php
    
    namespace Templates\JPVote\Php\Controllers;
    
    defined('Framework') or die();
    
    use Framework\Controllers\Controller;
    use Framework\Interfaces\IController;
    
    use Templates\JPVote\Php\Models\PollUrlRequestModel;
    
    class IndexController extends Controller implements IController
    {
  public function Initialize() // initialize method
  {
   $this->GetModel()->SetTitle(null);
   $this->GetModel()->SetPolls(array());
   $this->GetModel()->SetOlderPolls(array());
  }


There are some restrictions about this. The namespace must be the same as your folder structure!
The speed of programming, there isn't much improvement (I quess even worse), but the code looks better eventually.

ps. the code above is an old source of mine, it has changed allot over the time!
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Update:

- Fixed the room threading system (for updates needed)
- Made a simple 'walk' system (which is teleporting)
- Make the users mouth move when talking
------------------------------------------------------------
autoloading in combination with namespaces is the way to go for me! In each file you get exactly to know what uses what and where it's from.

PHP:
######## somefile.php ########

<?php
 spl_autoload_extensions('.php');
    spl_autoload_register();
    
    use Templates\JPVote\Php\Controllers\IndexController;
    
    $controller = new IndexController();
$controller->Initialize();
?>

######## templates\jpvote\php\controllers\indexcontroller.php ########

<?php
    
    namespace Templates\JPVote\Php\Controllers;
    
    defined('Framework') or die();
    
    use Framework\Controllers\Controller;
    use Framework\Interfaces\IController;
    
    use Templates\JPVote\Php\Models\PollUrlRequestModel;
    
    class IndexController extends Controller implements IController
    {
  public function Initialize() // initialize method
  {
   $this->GetModel()->SetTitle(null);
   $this->GetModel()->SetPolls(array());
   $this->GetModel()->SetOlderPolls(array());
  }


There are some restrictions about this. The namespace must be the same as your folder structure!
The speed of programming, there isn't much improvement (I quess even worse), but the code looks better eventually.

ps. the code above is an old source of mine, it has changed allot over the time!

So there's no improved stability? Because if not, for now I'd rather do it on my own way since I don't really understand your code (at the moment). And I can see it's an old code since you're using wrong names (like Initialize except of initialize), not that it is a big deal, but I've always learnt to use camelCase for PHP, just like Java.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
New updates:

- The encryption has been edited in both the emulator and the website (using org.apache.commons.codec.digest.Crypt and PHP crypt($password, $username)
- The website for v1x is now in development. Logging is done.

Snippets:

PHP:
<td id="topbar-status" class="<?php if (!Members::isLoggedIn()) { echo 'not'; } ?>loggedin">
						<?php if (Members::isLoggedIn()) { echo 'Logged in as <b>' . Members::getUserObject()->username . '</b>'; } else { echo 'Not logged in.'; } ?>
				</td>

PHP:
if ($_SERVER['REQUEST_METHOD'] === 'POST') 
{
	if (isset($_POST['username'], $_POST['password']))
	{
		if (!empty($_POST['username']) && !empty($_POST['password']))
		{
			if (Members::tryLogin($_POST['username'], $_POST['password']))
			{
				header("Location: index.php");
			}
			else
			{
				$_SESSION['LOGIN_ERROR'] = 'Wrong Username/Password!';
			}
		}
		else
		{
			$_SESSION['LOGIN_ERROR'] = 'Please fill in your Habboname/password.';
		}
	}
	else
	{
		$_SESSION['LOGIN_ERROR'] = 'Please fill in your Habboname/password.';
	}
}

PHP:
<?php

final class Members
{
	public static function getUser()
	{
		if (!isLoggedIn())
		{
			return null;
		}
		
		return $_SESSION['H_USR'];
	}

	public static function isLoggedIn()
	{
		return (isset($_SESSION['H_USR']) && !empty($_SESSION['H_USR']));
	}
	
	public static function getUserByName($name)
	{
		$obj = Main::getDatabase()->fetchResult('SELECT * FROM `users` WHERE `username` = :name LIMIT 1', array(':name'), array($name));
		
		return $obj;
	}
	
	public static function addUser($name, $email, $password, $figure, $gender, $motto, $email, $dob)
	{
		$keys = array(':name', ':password', ':figure', ':gender', ':motto', ':email', ':dob');
		$values = array($name, $password, $figure, $gender, $motto, $email, $dob);
		
		Main::getDatabase()->executeQuery('INSERT INTO `users` (`username`,`password`,`figure`,`gender`,`motto`,`email`,`dob`) VALUES (\':name\',\':password\',\':figure\',\':gender\',\':motto\',\':email\',\':dob\');', $keys, $values);
	}
	
	public static function tryLogin($name, $password)
	{
		$obj = self::getUserByName($name);
		
		if ($obj == null)
		{
			return false;
		}
		else
		{
			if ($obj->password === crypt($password, $name))
			{
				$_SESSION['H_USR'] = $obj;
				
				return true;
			}
			else
			{
				return false;
			}
		}
	}
	
	public static function getUserObject()
	{
		if (!self::isLoggedIn())
		{
			return null;
		}
		
		return $_SESSION['H_USR'];
	}
}

?>
 
Skilled Illusionist
Joined
Apr 27, 2008
Messages
330
Reaction score
370
New updates:

- The encryption has been edited in both the emulator and the website (using org.apache.commons.codec.digest.Crypt and PHP crypt($password, $username)
- The website for v1x is now in development. Logging is done.

Snippets:

PHP:
<td id="topbar-status" class="<?php if (!Members::isLoggedIn()) { echo 'not'; } ?>loggedin">
						<?php if (Members::isLoggedIn()) { echo 'Logged in as <b>' . Members::getUserObject()->username . '</b>'; } else { echo 'Not logged in.'; } ?>
				</td>

PHP:
if ($_SERVER['REQUEST_METHOD'] === 'POST') 
{
	if (isset($_POST['username'], $_POST['password']))
	{
		if (!empty($_POST['username']) && !empty($_POST['password']))
		{
			if (Members::tryLogin($_POST['username'], $_POST['password']))
			{
				header("Location: index.php");
			}
			else
			{
				$_SESSION['LOGIN_ERROR'] = 'Wrong Username/Password!';
			}
		}
		else
		{
			$_SESSION['LOGIN_ERROR'] = 'Please fill in your Habboname/password.';
		}
	}
	else
	{
		$_SESSION['LOGIN_ERROR'] = 'Please fill in your Habboname/password.';
	}
}

PHP:
<?php

final class Members
{
	public static function getUser()
	{
		if (!isLoggedIn())
		{
			return null;
		}
		
		return $_SESSION['H_USR'];
	}

	public static function isLoggedIn()
	{
		return (isset($_SESSION['H_USR']) && !empty($_SESSION['H_USR']));
	}
	
	public static function getUserByName($name)
	{
		$obj = Main::getDatabase()->fetchResult('SELECT * FROM `users` WHERE `username` = :name LIMIT 1', array(':name'), array($name));
		
		return $obj;
	}
	
	public static function addUser($name, $email, $password, $figure, $gender, $motto, $email, $dob)
	{
		$keys = array(':name', ':password', ':figure', ':gender', ':motto', ':email', ':dob');
		$values = array($name, $password, $figure, $gender, $motto, $email, $dob);
		
		Main::getDatabase()->executeQuery('INSERT INTO `users` (`username`,`password`,`figure`,`gender`,`motto`,`email`,`dob`) VALUES (\':name\',\':password\',\':figure\',\':gender\',\':motto\',\':email\',\':dob\');', $keys, $values);
	}
	
	public static function tryLogin($name, $password)
	{
		$obj = self::getUserByName($name);
		
		if ($obj == null)
		{
			return false;
		}
		else
		{
			if ($obj->password === crypt($password, $name))
			{
				$_SESSION['H_USR'] = $obj;
				
				return true;
			}
			else
			{
				return false;
			}
		}
	}
	
	public static function getUserObject()
	{
		if (!self::isLoggedIn())
		{
			return null;
		}
		
		return $_SESSION['H_USR'];
	}
}

?>

You can log v5 packets on my Blunk V5 testhotel. You can find it on :)
 
Experienced Elementalist
Joined
Mar 21, 2012
Messages
207
Reaction score
81
My opinion about this project: why should you create an outdated emulator. I think there are not many people that are waiting for an v5 server.
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
My opinion about this project: why should you create an outdated emulator. I think there are not many people that are waiting for an v5 server.

That's your opinion, and I know, but I don't care either. I'm developing this for mostly myself and if anybody uses it it's cool but I don't care whether people will or not. But please don't discuss this being outdated on this thread. I just want discussion about the versions/ emulator / website itself, not about it being outdated. Thank you sir.
 
Custom Title Activated
Loyal Member
Joined
Oct 21, 2007
Messages
2,098
Reaction score
464
My opinion about this project: why should you create an outdated emulator. I think there are not many people that are waiting for an v5 server.

It's fun creating and exploring the old code of Habbo plus in my opinion anything above v35 is thrash.
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Way to go, Zak, you're actually saying the truth.

------

Some updates:

- Started the MUS system for Camera (the MUS sockets are from Blunk, the same as message creating, the rest (all camera poop) will be made by me with help from Cecer)

More is coming soon but I've got also other stuff to do so it is a bit slow ATM.
 
Newbie Spellweaver
Joined
Jun 2, 2014
Messages
34
Reaction score
2
The camera save the images in a Host?

This project is amazing Tha :)
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
As far as I know it sends the image as bytes to your server then its up to you on how to store it.

You're right it decodes the image and sends the bytes with MUS (not RCON as most of the people call RCON MUS (RCON = connection between website and server)), and I will store them in a database table, since that's the best way.
 
Joined
Aug 10, 2011
Messages
7,399
Reaction score
3,308
You're right it decodes the image and sends the bytes with MUS (not RCON as most of the people call RCON MUS (RCON = connection between website and server)), and I will store them in a database table, since that's the best way.

Then in all honesty, whats the client then? Proof me its not a website :p:

Only the Habbo community uses the term MUS (port / connection) for a socket to the server from anything elsewhere than the client swf / dcr
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Then in all honesty, whats the client then? Proof me its not a website :p:

Only the Habbo community uses the term MUS (port / connection) for a socket to the server from anything elsewhere than the client swf / dcr

MUS -> The camera poop
RCON -> The website/server poop

Maarten told me this was the right explaination. People gave the name MUS for website/server connection while MUS is only for camera. The connection between website and server is called RCON.
 
Joined
Jun 23, 2010
Messages
2,324
Reaction score
2,195
Then in all honesty, whats the client then? Proof me its not a website :p:

Only the Habbo community uses the term MUS (port / connection) for a socket to the server from anything elsewhere than the client swf / dcr
Mus = MultiUserServer


I'm so gonna put that in my signature as I posted this serval times and people still don't get it. [emoji1]
 
Experienced Elementalist
Joined
Mar 21, 2012
Messages
207
Reaction score
81
Tell Maarten AKA vista4life that. I didn't make it up. But don't spam my Ducking thread!!!
Maarten and vista are right. But what you hear from others do you mix with other stuff without googling or asking.
 
Status
Not open for further replies.
Back
Top