[CMS][PHP/MySQLi] ZipCMS

Status
Not open for further replies.

IntactDev

Member
Nov 22, 2012
399
71
wvxljelAO3r0.png
Hello! I'm IntactDev, and you usually wouldn't find me in this section, but I've felt the need to create something that people would use... So, I've decided to make a Habbo CMS! I looked in this development section, and the last development was on March 24th, and that's no bueno, so I'm making a CMS that will compete with the commonly used UberCMS edits.​
Feature List:​
- TPL System [x]
- News System [x]
- Custom Made Default Theme [x]
- Advanced Backend [x]
Some planned features:
- Ability to buy/sell characters for credits.​
- Multiple characters via email.​
- News Comments.​
- Built-in forums.​
- Advanced Banning System (Ban IP, Ban Character, Ban E-Mail, Ban Country, Ban ISP, etc)​
Snippets:
common.php
PHP:
<?php
function zipError($title, $desc) {
 
    echo '<style type="text/css">';
    echo 'body { margin:0;font-family:Arial, sans-serif;font-size:13px;background:#DDD;color:#1A1A1A; }';
    echo 'h1 { color:#FFF;font-family:Arial;font-weight:bold;text-align:center; }';
    echo 'h2 { color:#1C1C1C;font-family:Arial;font-weight:bold;text-align:center;padding-bottom:4px;border-bottom:1px solid #AAA; }';
    echo '#error#head { background:#1C1C1C;padding:10px;;border-bottom:5px solid #FFF; }';
    echo '#error#content { border:1px solid #AAA;background:#FFF;padding:20px;width:780px;margin:30px auto; }';
    echo 'p { text-align:center;padding:10px;color:#1A1A1A;font-family:verdana; }';
    echo '</style>';
    echo '<title>' . $title . '</title>';
    echo '<div id="error head"><h1>An error has occurred.</h1></div>';
    echo '<div id="error content"><h2>'.$title.'</h2><p>'.$desc.'</p></div>';
}
 
function secure($string) {
    return stripslashes(htmlspecialchars($string));
}
 
function zipHash($string) {
    $hash = md5($string);
    $hash = substr($hash, 0, 8);
    $hash = md5($hash);
 
    return $hash;
}
 
?>

config.php
PHP:
<?php
$zip['Site']['Title']        = 'ZipCMS';
$zip['Site']['Location']    = 'http://localhost/ZipCMS'; # Include http:// in the URL #
 
$zip['Template']['Back']    = 'ZipCMS'; # The default template is ZipCMS #
$zip['Template']['Front']    = 'ZipCMS'; # The default template is ZipCMS #
 
$zip['Social']['Email']        = '[email protected]'; # E-Mail #
$zip['Social']['Twitter']    = 'IntactDev'; # Twitter #
$zip['Social']['Facebook']    = 'IntactDev'; # Facebook Ending Page URL#
 
$zip['MySQLi']['Hostname']    = 'localhost';
$zip['MySQLi']['Username']    = 'root';
$zip['MySQLi']['Password']    = 'xxxxxxxxxxxxx';
$zip['MySQLi']['Database']    = 'Zip';
 
?>

class.zcore.php
PHP:
<?php
 
class zCore {
 
    final public function getSetting($z) {
        global $db;
 
        $q = $db->query('SELECT * FROM  `zip_settings` WHERE variable = "' . $z . '"');
        while($return = $q->fetch_assoc()) {
            $done = $return['value'];
 
            return $done;
        }
    }
 
    final public function findFunction($z) {
        global $users, $zip, $db;
 
        $m = $this->getSetting('maintenance');
        if(!isset($z) || empty($z)) {
          $z = 'index';
        }
 
        if($m == 'false') {
            if(!isset($_SESSION['z']['user']['id'])) {
                switch($z) {
                    case 'index':
                    case null:
                    case 'lol':
                        $users->login();
                    break;
 
                    case 'register':
                        $users->register();
                    break;
                }
            } else {
                if(!isset($z) || empty($z)) {
                    $z = 'index';
                }
 
                switch($z) {
                    case 'index':
                    case 'register':
                        header("Location: " . $zip['Site']['Location'] . "/home");
                    break;
                }
            }
        }
    }
}
?>

class.ztpl.php
PHP:
<?php
 
class zTpl {
 
    private $params = Array();
    private $tpl;
 
    public function __construct() {
        global $zip;
 
        $this->Define('site: title', $zip['Site']['Title']);
        $this->Define('site: url', $zip['Site']['Location']);
        $this->Define('site: style', $zip['Site']['Location'] . '/_zip/_templates/_front/' . $zip['Template']['Front']);
 
        #$this->Define('stats: online', $this->);
 
        $this->Define('social: email', $zip['Social']['Email']);
        $this->Define('social: twitter', $zip['Social']['Twitter']);
        $this->Define('social: facebook', $zip['Social']['Facebook']);
    }
 
    public function filterParams($param) {
 
        foreach($this->params as $replace => $value) {
   
            $param = str_replace("{" .  $replace . "}", $value, $param);
        }
 
        return $param;
    }
 
    public function Write($str) {
      $this->tpl .= $str;
    }
 
    public function Define($key, $value) {
 
        $this->params[$key] = $value;
    }
 
    public function display() {
      echo $this->filterParams($this->tpl);
    }
 
    public function addTpl() {
        global $zip;
 
        if(!isset($_GET['url']) || empty($_GET['url'])) {
            $_GET['url'] = 'index';
        }
 
        if(file_exists('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php')) {
            ob_start();
            include('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php');
            $this->tpl .= ob_get_contents();
            ob_end_clean();
        } else {
            die(zipError('File Not Found', 'The file <b>' . secure($_GET['url']) . '</b> could not be found. Please re-check the URL; If you were directed here using a link, please report that link.'));
        }
    }
}
?>

login code
PHP:
final public function login() {
        global $db, $tpl;
 
        $tpl->Define('login: error', null);
 
        if(isset($_POST['login'])) {
            if(isset($_POST['username']) && isset($_POST['password'])) {
                $username = secure($_POST['username']);
                $password = secure($_POST['password']);
 
                $q = $db->query("SELECT * FROM users WHERE username = '{$username}' LIMIT 1");
                $num_rows = $q->num_rows;
                while($result = $q->fetch_assoc()) {
                    $dbPassword = $result['password'];
                    $dbId = $result['id'];
                    $banned = $result['id'];
                }
 
                if($num_rows > 0) {
                    if(zHash($password) == $dbPassword) {
                        if($banned == 0) {
                            $_SESSION['z']['user']['id']        =    $dbId;
                            $_SESSION['z']['user']['username']    =    $username;
 
                            $_SESSION['z']['logged_in']        =    true;
 
                            header("Location: /index");
                        } else {
                            header("Location: /banned");
                        }
                    } else {
                        $tpl->Define('login: error', '<div id="errmsg" class="cr">The password you entered does not match our records!</div><br />');
                    }
                } else {
                    $tpl->Define('login: error', '<div id="errmsg" class="cr">The username you have entered has not yet been registered!</div><br />');
                }
            } else {
                $tpl->Define('login: error', '<div id="errmsg" class="cr">Please complete all the fields!</div><br />');
            }
        }
    }

Screenshots:
index
5186d1a70b06f.jpg
login (error)
e6ff1722994c0ec2db0fb88addd4601d754f33668d.png
Notes:
I will have snippets and screenshots up within 24 hours, as I'm just starting this project, but it won't take me that long to have the building blocks completed.
The current theme is called "Fuze", which was released as an index, but I will continue it and make all the pages (staff, news, me, register, etc).​
Credits:
All my Haters: 99.9% --> For hating, obviously.​
Myself: 0.1% --> Coding ZipCMS.​
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Thread aproved. Good luck with this.

Please add some snippets/screens though otherwise the thread will be closed.
 

Dayron1234

Rapnameiszero,cuzIhavezero,toleranceforidiots
Jun 30, 2010
772
35
I rarely come into this section due to inactivity, but this CMS brought in here so good luck, I can't wait for the finished product.
 

IntactDev

Member
Nov 22, 2012
399
71
UPDATES:

- Templating system has been completed.
- Login & Registration has started.
- Main template has been started.
5186d1a70b06f.jpg


NOTES:
- More updates will be coming soon; I will make a demo-website and a github page so you can track the development. In the mean time, follow the development via Twitter:

 

Dann

ohi
Jan 26, 2013
234
49
Looks pretty good. Not sure whether I'd use it over UberCMS, but I haven't seen a lot of the CMS. Any extra features that the site will have on it? (e.g. news comments).
 

IntactDev

Member
Nov 22, 2012
399
71
great question.

Some planned features:

- Ability to buy/sell characters for credits.
- Multiple characters via email.
- News Comments.
- Built-in forums.
- Advanced Banning System (Ban IP, Ban Character, Ban E-Mail, Ban Country, Ban ISP, etc)

Those are just a few off the top of my head.
 

Dann

ohi
Jan 26, 2013
234
49
Another question..
Will this be able to have multiple database options (like uber has butterfly and phoenix) or just one/the other?
 

IntactDev

Member
Nov 22, 2012
399
71
Another question..
Will this be able to have multiple database options (like uber has butterfly and phoenix) or just one/the other?
As of now, I'm sticking with Phoenix, then I'll do the next most-common option. But yes, there eventually will be multiple databases.

UPDATES:
- The login has been fully coded, works 100%.
- Login has error handling, with brief error reports (user doesn't exists, banned, wrong password, empty fields, etc)

Weekly Goals:
- Finish register
- Finish me page
- Finish banned page

login code
PHP:
final public function login() {
        global $db, $tpl;
 
        $tpl->Define('login: error', null);
 
        if(isset($_POST['login'])) {
            if(isset($_POST['username']) && isset($_POST['password'])) {
                $username = secure($_POST['username']);
                $password = secure($_POST['password']);
 
                $q = $db->query("SELECT * FROM users WHERE username = '{$username}' LIMIT 1");
                $num_rows = $q->num_rows;
                while($result = $q->fetch_assoc()) {
                    $dbPassword = $result['password'];
                    $dbId = $result['id'];
                    $banned = $result['id'];
                }
 
                if($num_rows > 0) {
                    if(zHash($password) == $dbPassword) {
                        if($banned == 0) {
                            $_SESSION['z']['user']['id']        =    $dbId;
                            $_SESSION['z']['user']['username']    =    $username;
 
                            $_SESSION['z']['logged_in']        =    true;
 
                            header("Location: /index");
                        } else {
                            header("Location: /banned");
                        }
                    } else {
                        $tpl->Define('login: error', '<div id="errmsg" class="cr">The password you entered does not match our records!</div><br />');
                    }
                } else {
                    $tpl->Define('login: error', '<div id="errmsg" class="cr">The username you have entered has not yet been registered!</div><br />');
                }
            } else {
                $tpl->Define('login: error', '<div id="errmsg" class="cr">Please complete all the fields!</div><br />');
            }
        }
    }


e6ff1722994c0ec2db0fb88addd4601d754f33668d.png
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,398
962
PHP:
<?php
function zipError($title, $desc) {
 
    echo '<style type="text/css">';
    echo 'body { margin:0;font-family:Arial, sans-serif;font-size:13px;background:#DDD;color:#1A1A1A; }';
    echo 'h1 { color:#FFF;font-family:Arial;font-weight:bold;text-align:center; }';
    echo 'h2 { color:#1C1C1C;font-family:Arial;font-weight:bold;text-align:center;padding-bottom:4px;border-bottom:1px solid #AAA; }';
    echo '#error#head { background:#1C1C1C;padding:10px;;border-bottom:5px solid #FFF; }';
    echo '#error#content { border:1px solid #AAA;background:#FFF;padding:20px;width:780px;margin:30px auto; }';
    echo 'p { text-align:center;padding:10px;color:#1A1A1A;font-family:verdana; }';
    echo '</style>';
    echo '<title>' . $title . '</title>';
    echo '<div id="error head"><h1>An error has occurred.</h1></div>';
    echo '<div id="error content"><h2>'.$title.'</h2><p>'.$desc.'</p></div>';
}
lmao... if you're making a template system, wtf are you doing this horrid stuff?

look at template frameworks, and you'll see exactly why this is inefficient and just bad practice
 

IntactDev

Member
Nov 22, 2012
399
71
lmao... if you're making a template system, wtf are you doing this horrid stuff?

look at template frameworks, and you'll see exactly why this is inefficient and just bad practice
Hmm, that was just a function from an old project; and I see your point. Thanks for pointing that out, I'll recode it to be more efficient.
 

Leader

github.com/habbo-hotel
Aug 24, 2012
1,031
307
Base it on Butterfly. Even,BcStorm isnt 100% phoenix. It onlt uses Phoenix SSO so the cms will die when its done. Add a plugin manager on ASE and switch to Butterfly

Ex Post Facto
 

IntactDev

Member
Nov 22, 2012
399
71
Base it on Butterfly. Even,BcStorm isnt 100% phoenix. It onlt uses Phoenix SSO so the cms will die when its done. Add a plugin manager on ASE and switch to Butterfly

Ex Post Facto
It's going to use multiple databases, as I know some hotels are still using Pheonix Cracked, or the Self-hosting Pheonix that released.
 

IntactDev

Member
Nov 22, 2012
399
71
UPDATES:
- Register function has been completed.
- Organized file structure a little bit.
- Add more CSS.
- Modified login page to be a register page.

Weekly Goals:
- Finish register
- Finish me page
- Finish banned page

CODES:
register function
PHP:
final public function register() {
        global $db, $tpl, $zip;
 
        $tpl->Define('register: error', null);
 
        if(isset($_POST['register'])) {
            if(!empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['rep_password'])) {
                $username    = secure($_POST['username']);
                $email        = secure($_POST['email']);
                $password    = secure($_POST['password']);
                $password2    = secure($_POST['rep_password']);
 
                $q = $db->query("SELECT * FROM users WHERE username = '{$username}' LIMIT 1");
                $num_rows = $q->num_rows;
 
                if($num_rows < 1) {
                    if($password == $password2) {
                        if(validEmail($email)) {
                            if(strlen($password) >= 7) {
                                $this->insertUser($username, zHash($password), $email);
 
                                $_SESSION['register']['completed'] = '<div id="goodmsg" class="cr">You have successfully registered! Please login below.</div><br />';
 
                                header("Location: " . $zip['Site']['Location'] . "/index");
                            } else {
                                $tpl->Define('register: error', '<div id="errmsg" class="cr">Please enter a more secure password.</div><br />');
                            }
                        } else {
                            $tpl->Define('register: error', '<div id="errmsg" class="cr">Please enter a valid e-mail address.</div><br />');
                        }
                    } else {
                        $tpl->Define('register: error', '<div id="errmsg" class="cr">The passwords you entered do not match!</div><br />');
                    }
                } else {
                    $tpl->Define('register: error', '<div id="errmsg" class="cr">The username you have entered has already been registered!</div><br />');
                }
            } else {
                $tpl->Define('register: error', '<div id="errmsg" class="cr">Please complete all the fields!</div><br />');
            }
        }
    }

insertUser function
PHP:
final public function insertUser($username, $password, $email) {
        global $db;
 
        $ip = $_SERVER['REMOTE_ADDR'];
 
        if($stmt = $db->prepare('INSERT INTO users (username, password, mail, ip_last, ip_reg, auth_ticket) VALUES (?,?,?,?,?,?)'))  {
          $stmt->bind_param('ssssss', $username, $password, $email, $ip, $ip, $this->zSSO());
          $stmt->execute();
          $stmt->close();
        }
}

sso function
PHP:
final public function zSSO() {
        return 'z-' . rand(50, 100) . '-z-' . rand(25, 100) . '-z-' . rand(85, 300) . '-z';
    }


SCREENSHOTS:
e6ff172299d4239aa7be1ad0589b8204fa60778c91.png


e6ff172299de7764914baa7a5a394c7f982a47972d.png
 

Tranquilizer

Active Member
Jan 24, 2012
164
16
I would appreciate if you give me some credits for using my register button.. Other than that, it will be nice to have another CMS to choose from :)
 

Baevus

the names ethan
Nov 4, 2012
565
47
Register should take you straight to me. Makes it seem more neat.
Just my opinion
 
Status
Not open for further replies.

Users who are viewing this thread

Top