Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
Tha
UPDATE:
- Talking works
- Shouting works
- Started room update system
- Catalogue items
------------------------------------------------------------------------------------------------------
Besides that maybe.
Yeah, well, for V18 (if it's going to be V18, maybe it'll be V13 or V14 or somethin' like that) I'll use a CMS with login as it supports SSO. I think It'll be the best I choose the 2003 layout for v5 and 2006 for v13+. Not sure though.
I respect you for that project and for your effort!
An answer: I think that the catalogue loading furniture will be faster than the old r18 server, no?
Good work man & sorry for my English ;)
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Started the website for v1x (this is somewhere around v13 or somethin', don't know yet). I'm not a master in PHP like Joopie so if you see me doing something COMPLETELY wrong, don't flame and hate me and say 'YOU NOOB THAT IS BAD', but explain me the things I'm doing wrong. I haven't done much in PHP so I 'lack skills', not really much, but I'm not great.
Global.php:
PHP Code:
<?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();
?>
main.class.php:
PHP Code:
<?php
final class Main
{
private static $config;
private static $database;
private static $hotelname;
private static $shortname;
public static function initialize()
{
self::$config['MySQL']['hostname'] = 'localhost';
self::$config['MySQL']['username'] = 'root';
self::$config['MySQL']['password'] = '';
self::$config['MySQL']['database'] = 'website_v18';
self::$database = new Database();
$obj = self::$database->fetchResult('SELECT `hotelname`,`shortname` FROM `settings` LIMIT 1;');
self::$hotelname = $obj->hotelname;
self::$shortname = $obj->shortname;
}
public static function getValue($category, $key)
{
if (array_key_exists($category, self::$config))
{
if (array_key_exists($key, self::$config[$category]))
{
return self::$config[$category][$key];
}
}
return null;
}
public static function getHotelname()
{
return self::$hotelname;
}
public static function getShortname()
{
return self::$shortname;
}
}
?>
database.class.php:
PHP Code:
<?php
class Database
{
private $conn;
public function __construct()
{
$this->conn = new PDO('mysql:host=' . Main::getValue('MySQL', 'hostname') . ';dbname=' . Main::getValue('MySQL', 'database') . ';charset=utf8', Main::getValue('MySQL', 'username'), Main::getValue('MySQL', 'password'));
}
public function executeQuery($query, $keys, $values)
{
if (!is_array($keys) || !is_array($values))
{
// Error...
return;
}
else if (count($keys) != count($values))
{
// Error...
return;
}
$stmt = $this->conn->prepare($query);
for ($i = 0; $i < count($keys); $i++)
{
$stmt->bindValue(array_pop($keys), array_pop($values));
}
$stmt->execute();
}
public function fetchResultSet($query, $keys, $values)
{
if (!is_array($keys) || !is_array($values))
{
// Error...
return;
}
else if (count($keys) != count($values))
{
// Error...
return;
}
$stmt = $this->conn->prepare($query);
for ($i = 0; $i < count($keys); $i++)
{
$stmt->bindValue(array_pop($keys), array_pop($values));
}
$stmt->execute();
return $stmt->fetchAll();
}
public function fetchResult($query, $keys = array(), $values = array())
{
if (!is_array($keys) || !is_array($values))
{
// Error...
return;
}
else if (count($keys) != count($values))
{
// Error...
return;
}
$stmt = $this->conn->prepare($query);
for ($i = 0; $i < count($keys); $i++)
{
$stmt->bindValue(array_pop($keys), array_pop($values));
}
$stmt->execute();
return $stmt->fetch(PDO::FETCH_OBJ);
}
}
?>
It's written from scratch and the reason behind all those classes is (almost) no SQL queries anywhere besides the classes, so I made a class for things that has SQL queries, just to make it organized.
---------------------------------------------------------------------------------------------------
Project is still going on. I'm slowly continueing the room system but I don't know whether I'm doing it right or wrong. The status system of v5 is kind of a bitch to be honest. For some reason if I click on buy (for buying a weapon) I get no request, don't know why.
Updates will be very soon. I think this week / next week there will be an update (hopefully a huge one... :-))
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
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
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
iGalaxy
@
Tha
PHP Code:
<?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 Code:
<?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,
click here.
Autoload is more a thing of praticity, than 'code stability'. He already did it. No need to do it again, and read documentations, etc.
Documentation is right here: http://php.net/manual/en/language.oop5.autoload.php
- - - Updated - - -
Quote:
Originally Posted by
sahdsak
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
He can, but I don't think the point of that is to connect with newer hotels. Besides that, Users table of phoenix have hashed passwords, and some CMSs changes the blowfish or whatever, so at v5 would be impossible to him to follow that without having proper knowledge of each one's CMS (some have from scratch, some have rev, some have uber...).
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
sahdsak
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.
Quote:
Originally Posted by
iGalaxy
@
Tha
PHP Code:
<?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 Code:
<?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,
click here.
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.
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
Tha
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 Code:
######## 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!
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Update:
- Fixed the room threading system (for updates needed)
- Made a simple 'walk' system (which is teleporting)
- Make the users mouth move when talking
------------------------------------------------------------
Quote:
Originally Posted by
Joopie
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 Code:
######## 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.
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
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 Code:
<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 Code:
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 Code:
<?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'];
}
}
?>
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
Mr Game N Watch
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 Code:
<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 Code:
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 Code:
<?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 http://23.95.121.95/ :)
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
=dj.matias=
Should've said earlier and it would've been more use but thanks for the offering I still have MOST of the packets but not all, it's still a good thing :)
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
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.
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
Mextur
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.
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
@Mr Game N Watch
When do you think finish this project? And do you think release it for free? Thanks :)
Re: Project 'Habbo Shockwave Revival' - V5/V18 - Java - From Scratch - Encryption
Quote:
Originally Posted by
NIBU
@
Mr Game N Watch
When do you think finish this project? And do you think release it for free? Thanks :)
- I need to finish up a lot I don't know but I think within 2-3 months at least.
- Yes, because this forum doesn't allow paid-development threads, so yes, it's free.