• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

BandzCMS [PHP] [PDO] [RainTPL] [Caching]

Status
Not open for further replies.
Experienced Elementalist
Joined
Apr 25, 2012
Messages
222
Reaction score
35
Fixed a few buggs. Starting on the other pages now.
 
Experienced Elementalist
Joined
Apr 25, 2012
Messages
222
Reaction score
35
Looks pretty good so far, would love to see more PHP snippets :rolleyes:

PHP:
<?php

class User extends TableHolder {
	
	public static function getTable ()
	{
		return 'users';
	}
	public static function getIdentifyingRow ()
	{
		return 'id';
	}
	public function __construct ($id)
	{
		$query = $this->prepare ('SELECT * FROM users WHERE id = :id LIMIT 1');
		$query->execute (array (':id' => $id));
		
		if ($query->rowCount () < 1)
			exit ('<strong>BandzCMS Element -></strong> No user with ID '. $id);
		
		$this->identifier = $id;
		$this->data = $query->fetch (PDO::FETCH_ASSOC);
	}
	
	public function login ($password)
	{
		return crypt ($password, '$2y$10$'. $this->data ['salt']) == $this->data ['password'];
	}
	public function isBanned ()
	{
		$query = $this->prepare ("SELECT id FROM bans WHERE value = :id AND bantype = 'ip' LIMIT 1");
		$query->execute (array (':id' => $this->identifier));
		return $query->rowCount () > 0;
	}
	
	public function canHK ()
	{
		return $this->hasPermission ('hk_login');
	}
	
	public function hasPermission ($perm)
	{
		$notperm = ($perm[0] == '-' ? substr ($perm, 1, strlen ($perm)) : '-'. $perm);
		$rank = new Rank ($this->data ['rank']);
		$rankPerm = $rank->hasPermission ($perm);
		
		$userPerms = explode (',', $this->data['permissions']);
		
		if ($rankPerm && !in_array ($notperm, $userPerms))
			return true;
		
		return in_array ($perm, $userPerms);
	}
	public static function register ($username, $mail, $password)
	{
		if (static::has (['username' => $username]) || static::has (array ('mail' => $mail)))
			throw new Exception ('Such a user/mail already exists.');
		
		$salt = substr (bin2hex(openssl_random_pseudo_bytes(23)), 0, 22);
		
		$query = static::prepare ('INSERT INTO users (username, mail, password, salt) VALUES (:username, :mail, :password, :salt)');
		$query->execute (array (
			':username' => $username,
			':mail' => $mail,
			':password' => crypt ($password, '$2y$10$'. $salt),
			':salt' => $salt
		));
		
		return new User (static::getPDO ()->lastInsertId ());
	}
	
}

Here you go.
 
Experienced Elementalist
Joined
Apr 25, 2012
Messages
222
Reaction score
35
I don't really like the news reactions. I think the box is way too big. Are you using multiple pages?

I changed it a bit. We are starting now on the community page & the VIP Shop / Badge Shop
 
Newbie Spellweaver
Joined
Feb 23, 2013
Messages
80
Reaction score
26
Check
Code:
[B]C:\WT-NMP\WWW\habbo\application\classes\class.raintpl.php on line [B]268
[/B][/B]
 
Newbie Spellweaver
Joined
Aug 29, 2013
Messages
57
Reaction score
6
@RetroMakerD Because i have a server to pay, a TCP proxy to pay, i need to pay some coders.
And because i like some income. It's not that big of deal, because i will add them all on the bottom of the page.

And oh, if you are wondering who the * i am!
I'm Nick, one of the main developers :$

You wont get income if nobody sees it :p
 
Newbie Spellweaver
Joined
Mar 26, 2014
Messages
50
Reaction score
5
@RetroMakerD Because i have a server to pay, a TCP proxy to pay, i need to pay some coders.
And because i like some income. It's not that big of deal, because i will add them all on the bottom of the page.

And oh, if you are wondering who the * i am!
I'm Nick, one of the main developers :$
how will you keep people from removing your ads, when you release the cms?
 
Experienced Elementalist
Joined
Apr 25, 2012
Messages
222
Reaction score
35
We just did a speedtest , here is the result :

J4Ajz9N - BandzCMS [PHP] [PDO] [RainTPL] [Caching] - RaGEZONE Forums
 
Joined
Aug 10, 2011
Messages
7,399
Reaction score
3,308
I like the design.
Just a tip:

PHP:
if (! (ACCESS_LEVEL == 'ACCESS_ALL' || ACCESS_LEVEL == 'ACCESS_GUESTS' || ACCESS_LEVEL == 'ACCESS_USERS' || ACCESS_LEVEL == 'ACCESS_ADMIN'))

PHP:
if (ACCESS_LEVEL != 'ACCESS_ALL' && ACCESS_LEVEL != 'ACCESS_GUESTS' && ACCESS_LEVEL != 'ACCESS_USERS' && ACCESS_LEVEL != 'ACCESS_ADMIN')

Or you could just use an in_array call there.

Isn't the first one faster as it only has to check atleast once whereas the bottom one it has to check each and every comparison.
 
I don't even know
Loyal Member
Joined
Apr 7, 2010
Messages
1,699
Reaction score
420
Isn't the first one faster as it only has to check atleast once whereas the bottom one it has to check each and every comparison.

First one: Equal = Stop (Because it is true), Unequal = Continue
Second one: Unequal = Continue, Equal = Stop

They are literally the same, except one has to reverse the end-bool which means 1-3 more OPCodes
 
Custom Title Activated
Loyal Member
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Isn't the first one faster as it only has to check atleast once whereas the bottom one it has to check each and every comparison.
It depends on the values. In the first example, it will check if ACCESS_LEVEL is 'ACCESS_ALL', and if it isn't, it will check the second one. So, if access level is 'ACCESS_ADMIN', it'll check the same amount as the second one. It's slightly better but you barely notice the difference.
 
I don't even know
Loyal Member
Joined
Apr 7, 2010
Messages
1,699
Reaction score
420
PHP:
$bool = (ACCESS_LEVEL == 'ACCESS_ALL' || ACCESS_LEVEL == 'ACCESS_GUESTS' || ACCESS_LEVEL == 'ACCESS_USERS' || ACCESS_LEVEL == 'ACCESS_ADMIN');
if ($bool == false)
{
 //code
}

PHP:
if (ACCESS_LEVEL != 'ACCESS_ALL')
{
 if (ACCESS_LEVEL != 'ACCESS_GUESTS')
 {
  if (ACCESS_LEVEL != 'ACCESS_USERS')
  {
   if (ACCESS_LEVEL != 'ACCESS_ADMIN')
   {
    //Code
   }
  }
 }
}

IIRC, the PHP compiler/parser can optimise the second one to run like that ^, but the first one first has to calculate the entire value of $bool and then check if it equals false.
 
Junior Spellweaver
Joined
Feb 2, 2015
Messages
181
Reaction score
86
This guy has not written any of the PHP code himself, or at least, not much of it. I know, because I have made this myself.

You can download the CMS here, it's actually called VibeCMS and I wrote it for vibehotel.nl, but they don't use my CMS anymore:
https://mega.co.nz/#!YttWzJAb!9etqzq84frt9MBVmccDnV317nO2Y1Hi7x4SunjULtxQ
The database is a standard PhoenixEmu DB, but you'll need some extra tables which can be found here:
https://mega.co.nz/#!MtUTjAiZ!kEZxgCuXuW5bZ9z4kDzwNFOweXlpnV04RaewVhznvVQ

The housekeeping is not finished yet, but I'll release one if you want me to :)

I did remove the template because they wanted to have it for themselves, all fine, but so: you'll have to make one yourself, but it's not all that difficult, look around in the PHP-code and make something yourself)

~ Xesau

PS: Jer, I don't mind you using my code, but at least give some credits...
PS2: If you don't believe me: look at the file dates in the ZIP. Says enough doesnt it?
 
Last edited:
Newbie Spellweaver
Joined
Feb 26, 2013
Messages
60
Reaction score
24
Yeah I kind of was expecting this. He and a few others (including me) starter a habbo cms. I created the template and soms other guy created the PHP. This guy just stole all of our content and claims it as his while he had done nothing so far. This is just ons big fake system. Nothing is written by him.
 
Joined
Aug 10, 2011
Messages
7,399
Reaction score
3,308
Yeah I kind of was expecting this. He and a few others (including me) starter a habbo cms. I created the template and soms other guy created the PHP. This guy just stole all of our content and claims it as his while he had done nothing so far. This is just ons big fake system. Nothing is written by him.

If you could provide proof of this (chatlogs, screenshots etc.) to the moderators of this section the thread can be removed. Contact them through PM.
 
Junior Spellweaver
Joined
Feb 2, 2015
Messages
181
Reaction score
86
This was one of the guys I worked with.
I have already given proof. Look at the file dates in the ZIP.
 
Status
Not open for further replies.
Back
Top