Junior Spellweaver
- Joined
- Feb 2, 2015
- Messages
- 181
- Reaction score
- 86
µHabbo 2.0
The best a man can get
- Flexibility
(e.g. you can use the CMS with just emulator) - Modularity
(e.g. you have to change many files in order to make little adaptations) - Safety
(e.g. people on a forum can add [img]You must be registered to see links[/img] to their signature, to log you out)
Another feature is that the CMS can answer each request with an HTML-response or a JSON-respons, depening on the HTTP Accept header. This way, you can easily AJAX-ify your theme's!
Libraries
µHabbo will use some libraries. In previous versions (≤ 1.6.2b) it utilized my own framework, yet that didn't seem to work well. The libraries µHabbo uses in version 2.0 are:
-
You must be registered to see links
-
You must be registered to see links
- Xesau/Events (not available online yet)
-
You must be registered to see links(for template rendering)
Progress
- Facebook login
- Minimail
Snippets
The code for the |translate-filter for templates:
PHP:
function translate($string)
{
global $lang;
$result = array_key_exists($string, $lang) ? $lang[$string] : $string;
if (func_num_args() != 1)
{
$first = func_get_arg(1);
if(is_array($first))
foreach ($first as $key => $value)
$result = str_replace('%'. $key, $value, $result);
else
for ($i = func_num_args() - 1; $i > 0; $i--)
$result = str_replace('%'. $i, func_get_arg($i), $result);
}
return $result;
}
Login controller
PHP:
static function login()
{
if (CSRF != @$_POST['csrf_token'])
exit();
$login = @$_POST['login_login'];
$password = @$_POST['login_password'];
$remember = @$_POST['login_remember'];
try {
$user = User::select()
->where(\db('user', 'username'), QB::EQ, $login)
->whereOr(\db('user', 'email'), QB::EQ, $login)
->find();
if (password_verify($password, $user->getPassword()))
{
// If remembered, login for a year, else for two hours
$expireTime = time() + ($remember ? 31536000 : 7200);
$session = Session::create($user, $_SERVER, $expireTime);
if (HTTP_ACCEPT == 'JSON') {
exit('{"success": true, "session_id": '. $session->id() .'}');
} else {
setcookie(COOKIEPF.'ssid', $session->id(), $expireTime, '/');
App::redirect('');
}
} else {
if (HTTP_ACCEPT == 'JSON') {
exit('{"success": false, "error": "password_incorrect"}');
} else {
App::showMessage('error', 'error.login.password_incorrect', true);
App::saveField('login_login', $login);
App::redirect('');
}
}
} catch (RangeException $ex) {
if (HTTP_ACCEPT == 'JSON') {
exit('{"success": false, "error": "login_not_found"}');
} else {
App::showMessage('error', 'error.login.login_not_found', true);
App::saveField('login_login', $login);
App::redirect('');
}
}
}
FAQ
Will this be released?
Yes it will. Also it will be completely free of charge.
A few plugins will be available too. If you really desperately need to show your support, there will be some premium plugins with higher complexity.
When will this be finished?
Whenever it's usable. Alpha releases will be distributed along the way of development.
Why don't you use [insert framework here]?
You haven't read properly. I tried using a framework in the 1.x iteration of this project, but it didn't work as well as I hoped it would, hence I decided to use separate components, listed in the Libraries-section.
Can I download this already?
Sure! There is an older version available, 1.6.2b.
You must be registered to see links
Last edited: