- Joined
- Apr 30, 2007
- Messages
- 2,339
- Reaction score
- 1,547
Sleeve CMS
Utilizing XCache, MySQL Improved and Rain TPL
Object Oriented PHP Habbo CMS
Utilizing XCache, MySQL Improved and Rain TPL
Object Oriented PHP Habbo CMS
Current Feature-set:
- Login
- Quick Register
- Articles
- Community
- Trusted Dealers feature
- Staff page
- Checking for bans
- Hot rooms widget
- Tags widget
- Changing passwords
- Badge Shop feature
- Me Page and related objects
- Caching with TTL for 99% of CMS features
- Cache expiry for logged out users / inactive players
- Instant page loading
- Really Ducking easy to set up and use
- Full housekeeping / website & hotel managament panel (does not use caching.)
Screenshots:
Code snippets:
Code:
private function CacheUserVariables($username, $recache = false)
{
$this->key = strtoupper($username) . "_VARS";
if(!$recache)
{
if($this->rpmode)
{
}
else
{
$this->begin = $this->db->prepare("SELECT username,password,mail,rank,credits,activity_points,motto,ip_last,ip_reg,auth_ticket,online,look FROM users WHERE username = ?");
$this->begin->bind_param('s', $username);
$this->begin->execute();
$this->begin->bind_result($this->username, $this->password, $this->mail, $this->rank, $this->credits, $this->activity_points, $this->motto, $this->ip_last, $this->ip_reg, $this->auth_ticket, $this->onlinestatus, $this->look);
$this->begin->fetch();
$this->begin->close();
$this->insertArray = array(
"username" => $this->username,
"password" => $this->password,
"email" => $this->mail,
"rank" => intval($this->rank),
"credits" => intval($this->credits),
"pixels" => intval($this->activity_points),
"motto" => $this->motto,
"ip_last" => $this->ip_last,
"ip_reg" => $this->ip_reg,
"auth_ticket" => $this->auth_ticket,
"online" => intval($this->onlinestatus),
"look" => $this->look
);
xcache_set($this->key, json_encode($this->insertArray, true), 120);
}
}
}
Code:
public function GetRandomHabbos()
{
global $engine;
if(!xcache_isset("RANDOMHABBOS_GENERATED"))
{
$this->getHabbos = $engine->db->prepare("SELECT username,motto,look,online,account_created FROM users WHERE online = '1' LIMIT 18");
$this->getHabbos->execute();
$this->getHabbos->bind_result($this->username, $this->motto, $this->look, $this->online, $this->account_created);
$this->i = 0;
while($this->getHabbos->fetch())
{
$this->key = "RANDOMHABBOS_" . $this->i;
$this->toJson = array(
"RH_USERNAME" => $this->username,
"RH_MOTTO" => $this->motto,
"RH_LOOK" => $this->look,
"RH_ONLINE" => $this->online ? true : false,
"RH_CREATED" => $this->account_created
);
xcache_set($this->key, json_encode($this->toJson, true), 120);
$this->i++;
}
$this->getHabbos->close();
xcache_set("RANDOMHABBOS_GENERATED", true, 120);
xcache_set("RANDOMHABBOS_AMOUNT", $this->i, 120);
}
for($this->o = 0; $this->o < intval(xcache_get("RANDOMHABBOS_AMOUNT")); $this->o++)
{
$this->userInfo = json_decode(xcache_get("RANDOMHABBOS_" . $this->o));
$this->boxNum = $this->o;
echo '<div id="active-habbo-data-' . $this->boxNum . '" class="active-habbo-data">
<div class="active-habbo-data-container">
<div class="active-name online">' . $this->userInfo->{"RH_USERNAME"} . '</div>
<p class="moto"><b>Motto</b>: ' . $engine->core->FilterHtml($this->userInfo->{"RH_MOTTO"}) . '</p>
</div>
</div>
<input type="hidden" id="active-habbo-url-' . $this->boxNum . '" value="' . WWW . '/user/' . $this->userInfo->{"RH_USERNAME"} . '"/>
<input type="hidden" id="active-habbo-image-' . $this->boxNum . '" class="active-habbo-image" value="https://www.habbo.fr/habbo-imaging/avatarimage?figure=' . $this->userInfo->{"RH_LOOK"} . '&direction=4&head_direction=4" />';
}
}
I've done a fair bit in only a few days. I had an old base I coded utilizing APC but seeing as php doesn't officially support it anymore and it has issues with IIS (most retros use IIS to host their CMS) I decided to move to XCache. Practically the same syntax and a lot of people say it's better.
Not looking for suggestions, I'm good with how it works and looks. Stupid comments like oh hurp durp camelcase @Quackster are not required but thanks. I code in JontyCase which is whatever the hell i feel like typing at the time.
Gotta thank @Matthew for giving me the idea to use opcode caching in the first place, without him I would never have even looked into it. Calling from a DB on every page load is so 1990s.
I hope you like it :fanny:
Last edited: