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!

[DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented

Status
Not open for further replies.
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


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:

Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums




Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums

Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums


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:
Retired
Loyal Member
Joined
May 5, 2007
Messages
497
Reaction score
665
Finally someone who is using cache, but why not PDO instead of MySQLi?
Another thing:
Code:
$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();
Avoid using the ?. It is unreadable and totally unmaintainable when you have more than 3-4 variables. Adding a human readable name is far better because then it is actually possible to keep track of which variable is which.

Good luck!
 
Joined
Jun 23, 2010
Messages
2,324
Reaction score
2,195
Finally someone who is using cache, but why not PDO instead of MySQLi?
Another thing:
Code:
$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();
Avoid using the ?. It is unreadable and totally unmaintainable when you have more than 3-4 variables. Adding a human readable name is far better because then it is actually possible to keep track of which variable is which.

Good luck!
Sadly the only thing that mysqli lacks of is named parameters in a prepared statement, however with a simple regex expression you could add that feature verry easy.

Also, why do you do set the stmt resource in a property and not a variable?

But cache carefully, for example the hotel use some sort of payment currency, when in game buying stuff, the currency won't update in the cms...
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
Finally someone who is using cache, but why not PDO instead of MySQLi?
Another thing:
Code:
$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();
Avoid using the ?. It is unreadable and totally unmaintainable when you have more than 3-4 variables. Adding a human readable name is far better because then it is actually possible to keep track of which variable is which.

Good luck!

I chose MySQLi because it was easier for me to pick up when I first started OOP. I think PDO is probably better but I'm happy with what i've got for now.

As for your second comment I agree. Thanks man :)



Sadly the only thing that mysqli lacks of is named parameters in a prepared statement, however with a simple regex expression you could add that feature verry easy.

Also, why do you do set the stmt resource in a property and not a variable?

But cache carefully, for example the hotel use some sort of payment currency, when in game buying stuff, the currency won't update in the cms...

I never really saw a benefit to creating a variable to set as the stmt resource.

And yeah, I overlook some of those things when beginning on this but I'm sure with having source access to both the CMS and the Emulator I am developing I can work something out.
 
I don't even know
Loyal Member
Joined
Apr 7, 2010
Messages
1,699
Reaction score
420
Criticism: Why don't you just cache entire HTML widgets instead of the rows? It'll still run on the CPU every time the page is requested. My rule is: When you use cache, cache as much as possible. Secondly, people will probably not like the fact that you're using the old style index, register and news widget. The new layout is also far easier to code for, but if you like this layout, I won't judge you on your preference. What Joopie said is true, it's not really useful to keep the prepared statement in memory as a property, a simple variable would be much quicker.

This project looks promising, please make a clean CMS for the community. With all the RevCMS renames, we need a good CMS.

Offtopic: UpperCase Masterrace!
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
Criticism: Why don't you just cache entire HTML widgets instead of the rows? It'll still run on the CPU every time the page is requested. My rule is: When you use cache, cache as much as possible. Secondly, people will probably not like the fact that you're using the old style index, register and news widget. The new layout is also far easier to code for, but if you like this layout, I won't judge you on your preference. What Joopie said is true, it's not really useful to keep the prepared statement in memory as a property, a simple variable would be much quicker.

This project looks promising, please make a clean CMS for the community. With all the RevCMS renames, we need a good CMS.

Offtopic: UpperCase Masterrace!

I like this layout. Also, I don't cache HTML widgets because I want the people I'm developing this for to be able to edit things easily without having to modify any PHP code.
 
Joined
Dec 16, 2011
Messages
1,994
Reaction score
633
Great to see I'm not the only one caching my CMS, it truly does make a difference with loading times and memory use.

I've seen a few developments uncompleted by you Jonty, but let's hope this one gets complete, as it may look promising. Anything better than RevCMS & Uber is all I'm asking for. :fanny:

Good luck, :thumbup1:
 
Experienced Elementalist
Joined
May 30, 2013
Messages
288
Reaction score
242
Peeps are just now discovering that their server has this thing called 'random access memory'?! jeez.

Anyway, I wish you luck OP;
Obviously you'll need it if you plan to make this any better than your previous projects. :laugh:
 
Custom Title Activated
Loyal Member
Joined
May 23, 2011
Messages
1,607
Reaction score
589
Any particular reason as to why you're using xcache over something like memcached/redis/apc?
--
Also, I think Hoshiko *may* be PEJump, who once famously said "he doesn't need girls because he has his pc"
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
Any particular reason as to why you're using xcache over something like memcached/redis/apc?
--
Also, I think Hoshiko *may* be PEJump, who once famously said "he doesn't need girls because he has his pc"

This did use APC, but I found it more difficult to set up on IIS than Apache and seeing as most retro owners use IIS I moved to xcache cause it's easy as hell, plus I read somewhere that APC had stopped development, or was going to soon.
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
I ported my current housekeeping over, felt no need to create a new one. I coded it almost 2 years ago now though, so some code may be a little outdated. If I get time, I'll rewrite it. But for now, it can stay like this.

Jonteh - [DEV] Sleeve CMS - XCache - MySQLi - Templating - Object Oriented - RaGEZONE Forums
 
Status
Not open for further replies.
Back
Top