[DEV] simpleCMS [PHP / MySQL]

Baevus

the names ethan
Nov 4, 2012
565
47
simpleCMS ~ A simple content management system!

What is simpleCMS?
A little / simple content management system created (put together) by me!
You will notice less noobyness & more credits by me!

What does simpleCMS have?
- Usersystem [100%] ~ Credits to; Me for variable fixes
and

-
Database Structure [80%] ~ Credits to; Me for fixing up the users column and whole of news column
and

- User Panel [100%] ~ Credits to; Me for some BASIC (and I mean it) html fixes & separating files so its not all messy on 1 page.
and

- Theme [100%] ~ Credits to; Me & Sheldos (base design)

What does simpleCMS do?
It is more of a framework then a CMS but.. IT DOES ANYTHING!
You can covert it into a website for gaming or a theme for a habbo retro!

What will I be adding?
- Multi Themes
- An updated configuration!

Snippets?
PHP:
<?php

define('INCLUDE_CHECK',true);

require 'connect.php';
require 'functions.php';
// Those two files can be included only if INCLUDE_CHECK is defined


session_name('Login');
// Starting the session

session_set_cookie_params(2*7*24*60*60);
// Making the cookie live for 2 weeks

session_start();

if($_SESSION['id'] && !isset($_COOKIE['Remember']) && !$_SESSION['rememberMe'])
{
    // If you are logged in, but you don't have the Remember cookie (browser restart)
    // and you have not checked the rememberMe checkbox:

    $_SESSION = array();
    session_destroy();
   
    // Destroy the session
}


if(isset($_GET['logoff']))
{
    $_SESSION = array();
    session_destroy();
   
    header("Location: index.php");
    exit;
}

if($_POST['submit']=='Login')
{
    // Checking whether the Login form has been submitted
   
    $err = array();
    // Will hold our errors
   
   
    if(!$_POST['username'] || !$_POST['password'])
        $err[] = 'All the fields must be filled in!';
   
    if(!count($err))
    {
        $_POST['username'] = mysql_real_escape_string($_POST['username']);
        $_POST['password'] = mysql_real_escape_string($_POST['password']);
        $_POST['rememberMe'] = (int)$_POST['rememberMe'];
       
        // Escaping all input data

        $row = mysql_fetch_assoc(mysql_query("SELECT id,username FROM users WHERE username='{$_POST['username']}' AND password='".md5($_POST['password'])."'"));

        if($row['username'])
        {
            // If everything is OK login
           
            $_SESSION['username']=$row['username'];
            $_SESSION['id'] = $row['id'];
            $_SESSION['rememberMe'] = $_POST['rememberMe'];
           
            // Store some data in the session
           
            setcookie('Remember',$_POST['rememberMe']);
        }
        else $err[]='Wrong username and/or password!';
    }
   
    if($err)
    $_SESSION['msg']['login-err'] = implode('<br />',$err);
    // Save the error messages in the session

    header("Location: index.php");
    exit;
}
else if($_POST['submit']=='Register')
{
    // If the Register form has been submitted
   
    $err = array();
   
    if(strlen($_POST['username'])<4 || strlen($_POST['username'])>32)
    {
        $err[]='Your username must be between 3 and 32 characters!';
    }
   
    if(preg_match('/[^a-z0-9\-\_\.]+/i',$_POST['username']))
    {
        $err[]='Your username contains invalid characters!';
    }
   
    if(!checkEmail($_POST['email']))
    {
        $err[]='Your email is not valid!';
    }
   
    if(!count($err))
    {
        // If there are no errors
       
        $password = substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6);
        // Generate a random password
       
        $_POST['email'] = mysql_real_escape_string($_POST['email']);
        $_POST['username'] = mysql_real_escape_string($_POST['username']);
        // Escape the input data
       
       
        mysql_query("    INSERT INTO users(username,password,email,regIP,dt)
                        VALUES(
                       
                            '".$_POST['username']."',
                            '".md5($password)."',
                            '".$_POST['email']."',
                            '".$_SERVER['REMOTE_ADDR']."',
                            NOW()
                           
                        )");
       
        if(mysql_affected_rows($link)==1)
        {
            send_mail(    '',
                        $_POST['email'],
                        'simpleCMS ~ Your new password is!',
                        'Your password is: '.$password);

            $_SESSION['msg']['reg-success']='Your account has been created! Check your email for a password!';
        }
        else $err[]='There was an error with your registration! Try a different username or password!';
    }

    if(count($err))
    {
        $_SESSION['msg']['reg-err'] = implode('<br />',$err);
    }   
   
    header("Location: index.php");
    exit;
}

$script = '';

if($_SESSION['msg'])
{
    // The script below shows the sliding panel on page load
   
    $script = '
    <script type="text/javascript">
   
        $(function(){
       
            $("div#panel").show();
            $("#toggle a").toggle();
        });
   
    </script>';
   
}
?>


Screenshots?
You must be registered for see images attach

You must be registered for see images attach


Credits have been placed in thread!
-itsEthan
 

Attachments

  • simplecms.PNG
    simplecms.PNG
    45.9 KB · Views: 12

Sysode

Front-End Developer
Dec 11, 2012
1,673
848
The whole login thing (I know it's not yours) reminds me a bit of xF forums login.

Anyway, guessing this is for education purposes and I know nothing about back-end so I can't really judge anything here. However, looking at the demo from the actual script, the design hasn't changed too much - a lot could be done to spice that up a bit more :p

Keep at this and keep posting updates on what you've added/amended.
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Hope you can learn something from copying and pasting, seeming that on a post before you said

I don't know how to code

which means you're probably googling everything but maybe this is a good learning experience. You have to start somewhere. Goodluck.
 

brsy

nah mang
May 12, 2011
1,530
272
- Theme [100%] ~ Credits to; Me & Sheldos (base design)​

This is the exact design that was in the code demo, so how do the credits belong to you and Sheldos? Also, I don't see how this code works:

PHP:
if($_SESSION['id'] && !isset($_COOKIE['Remember']) && !$_SESSION['rememberMe'])
{
    // If you are logged in, but you don't have the Remember cookie (browser restart)
    // and you have not checked the rememberMe checkbox:

    $_SESSION = array();
    session_destroy();
  
    // Destroy the session
}
Maybe I'm missing something but here is what I'm reading:
  • if ID is set, but rememberme isn't set --> logout user.
So, if the user chooses to never check the remember me box, it will logout the user upon a simple page reload. I'm pretty sure that is a horrible idea, if I am reading that correctly. Perhaps take the feature from another source, like:


 

Baevus

the names ethan
Nov 4, 2012
565
47
This is the exact design that was in the code demo, so how do the credits belong to you and Sheldos? Also, I don't see how this code works:

PHP:
if($_SESSION['id'] && !isset($_COOKIE['Remember']) && !$_SESSION['rememberMe'])
{
    // If you are logged in, but you don't have the Remember cookie (browser restart)
    // and you have not checked the rememberMe checkbox:

    $_SESSION = array();
    session_destroy();

    // Destroy the session
}
Maybe I'm missing something but here is what I'm reading:
  • if ID is set, but rememberme isn't set --> logout user.
So, if the user chooses to never check the remember me box, it will logout the user upon a simple page reload. I'm pretty sure that is a horrible idea, if I am reading that correctly. Perhaps take the feature from another source, like:


I don't think I made it as clear but I changed the default design and took the user system to an advantage (custom pages for members only ect).
The automatic log out if not selected remember me is a bug I am trying to fix, it has automatically selected remember me. This is a start to me learning to code advanced php, sorry if its a bit dodgy.

Update:
Profile pages will be working soon!

LIVE DEMO: simple-cms.tk
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
You can't really give yourself credit is what we are trying to say.. There's a complete difference when you make a cms from scratch and give your self 100% credit.. and if you only change a few minor changes so like you update 1 variable, congrats that like 2% credit or less.. You didn't code the whole cms you copied it.

Honestly people that try to give themselves credit for copying and pasting code and trying to say they did all the work really get on my nerves:kryptos:

some of us actually spend a lot of time making the whole thing to get a few noobs like you to come and edit 2/3 things and take credit
 

brsy

nah mang
May 12, 2011
1,530
272
You can't really give yourself credit is what we are trying to say.. There's a complete difference when you make a cms from scratch and give your self 100% credit.. and if you only change a few minor changes so like you update 1 variable, congrats that like 2% credit or less.. You didn't code the whole cms you copied it.

Honestly people that try to give themselves credit for copying and pasting code and trying to say they did all the work really get on my nerves:kryptos:

some of us actually spend a lot of time making the whole thing to get a few noobs like you to come and edit 2/3 things and take credit
You can't put a percentage on credits regardless... that is just so inaccurate, unless you actually counted and averaged out how many lines of code you made, which still wouldn't be accurate.
 

Baevus

the names ethan
Nov 4, 2012
565
47
So I can't take credit for my theme? lolwut.
Yes the user system is taken, it is FREE to use. I didn't take credit for it, well I did but I did change quite a bit.

Update:
Members page is updated, working on profiles now.
 

Jaden

not so active
Aug 24, 2014
886
263
Keep on topic. Any off topic posts will be removed and warned.
Removed.
 
Last edited by a moderator:

Baevus

the names ethan
Nov 4, 2012
565
47
i cnt code but my custom cms is soo fuckin good jaycustoms im a fucking mastermind
yet i cnt code soz dude
I did not make it custom. I never said I did. I never said it was good. It is a start for me.
Mod please clean thread.
 

Baevus

the names ethan
Nov 4, 2012
565
47
Why are you closing thread this looks good m8. Plus i wasn't mocking you i was mocking JayCustoms
I'm not closing it lol, i'm cleaning it. Ohhh, I thought... nvm.
 
Update; I decided to go MySQLi, thanks to @TesoMayn for fixing up some errors. YES the code is messy :l soz.
PHP:
<?php
require 'connect.php';

// Create's Connection
$conn = new mysqli($db_host, $db_user, $db_pass, $db_database);
// Check's Connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
// Gets into database & posts data.
$sql = "SELECT id, username FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Data is now posted.
    while($row = $result->fetch_assoc()) {
       echo 'User ID: <b>' . $row["id"] . '</b> - Username: <b><a href="' . $row["username"] . '.php">' . $row["username"] . '</a></b><br />';
    }
} else {
    echo "There are no registered users!";
   }
$conn->close();':'
?>

Now I've got to work on profiles and release v1.0 should be out!
 
Sorry for triple-posting!
Downloads now up;


Profiles & News are disabled, news will be enabled in the next lot and profiles maybe v1.5?
 

marles

Member
Feb 5, 2011
34
2
Here's a simple class to manage your database.

PHP:
<?php

    class Database {

        protected $_con;
        protected $_query = '';
        protected $_where = array();
        protected $_whereTypeList = '';
        protected $_paramTypeList = '';

        protected $_bindParams = array('');
        public $queries_count;

        public function __construct($username = '',$password = '',$host = '',$database = '') {
            $this->con = new mysqli($host,$username,$password,$database);
            $this->queries_count = 0;
        }

        /**
         * Reset states after an execution
         * @return object Returns the current instance.
         */
        protected function reset()
        {
            $this->_where = array();
            $this->_bindParams = array('');        // Create the empty 0 index
            $this->_query = '';
            $this->_whereTypeList = '';
            $this->_paramTypeList = '';
        }

        /**
         *
         * @param string $query Contains a user-provided select query.
         * @param int $numRows The number of rows total to return.
         * @return array Contains the returned rows from the query.
         */
        public function query($query, $numRows = NULL)
        {
            $this->_query = filter_var($query, FILTER_SANITIZE_STRING);
            $stmt = mysqli_stmt_init($this->con);
            $stmt->prepare($query);
            $stmt->execute();
            $this->reset();

            $results = $stmt->get_result();
            $this->queries_count = $this->queries_count + 1;
            return $results;
        }

    }
?>

Call this
Code:
<?php
require 'connect.php';

// Create's Connection
$conn = new Database($db_host, $db_user, $db_pass, $db_database);

// Gets into database & posts data.
$sql = "SELECT id, username FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Data is now posted.
    while($row = $result->fetch_assoc()) {
       echo 'User ID: <b>' . $row["id"] . '</b> - Username: <b><a href="' . $row["username"] . '.php">' . $row["username"] . '</a></b><br />';
    }
} else {
    echo "There are no registered users!";
   }
?>

Don't know if it's secure or not... Been using it in my project...
 

Baevus

the names ethan
Nov 4, 2012
565
47
Here's a simple class to manage your database.

PHP:
<?php

    class Database {

        protected $_con;
        protected $_query = '';
        protected $_where = array();
        protected $_whereTypeList = '';
        protected $_paramTypeList = '';

        protected $_bindParams = array('');
        public $queries_count;

        public function __construct($username = '',$password = '',$host = '',$database = '') {
            $this->con = new mysqli($host,$username,$password,$database);
            $this->queries_count = 0;
        }

        /**
         * Reset states after an execution
         * @return object Returns the current instance.
         */
        protected function reset()
        {
            $this->_where = array();
            $this->_bindParams = array('');        // Create the empty 0 index
            $this->_query = '';
            $this->_whereTypeList = '';
            $this->_paramTypeList = '';
        }

        /**
         *
         * @param string $query Contains a user-provided select query.
         * @param int $numRows The number of rows total to return.
         * @return array Contains the returned rows from the query.
         */
        public function query($query, $numRows = NULL)
        {
            $this->_query = filter_var($query, FILTER_SANITIZE_STRING);
            $stmt = mysqli_stmt_init($this->con);
            $stmt->prepare($query);
            $stmt->execute();
            $this->reset();

            $results = $stmt->get_result();
            $this->queries_count = $this->queries_count + 1;
            return $results;
        }

    }
?>

Call this
Code:
<?php
require 'connect.php';

// Create's Connection
$conn = new Database($db_host, $db_user, $db_pass, $db_database);

// Gets into database & posts data.
$sql = "SELECT id, username FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Data is now posted.
    while($row = $result->fetch_assoc()) {
       echo 'User ID: <b>' . $row["id"] . '</b> - Username: <b><a href="' . $row["username"] . '.php">' . $row["username"] . '</a></b><br />';
    }
} else {
    echo "There are no registered users!";
   }
?>

Don't know if it's secure or not... Been using it in my project...
Looks a whole hell cleaner, but I think i'll just stick with mine. BUT i'll demo it.
 

brsy

nah mang
May 12, 2011
1,530
272
Any updates @itsEthan_ ? Been ~4 weeks since an update or any news.

Suggestions:
404 page.
The ability to enable or disable a specific page (hide a page from the navigation through a setting, probably from database).
Less padding on top of the header, and more padding under it.
BAsLr4W.png
 

Khalil

IDK
Dec 6, 2011
1,642
786
I used to go by the name 'Sheldos' a long time ago when I was still new on DevBest, I used that design on one of my very old projects (which I did post a thread about here), that's not mine (as if I recall correctly I stated on the thread and did give credits, that is, if I recall correctly), I remember putting my hands on it when I google'd some free css releases or whatever the hell I google'd. That's when I found: .

Anywho, I'm not really sure about this project of yours, I mean, the code sample does look ok and all (except some parts that make me want to go into a corner and cry my eyes out all night), but I'm not too sure about the idea. Would you care to explain more? Oh and guys, please take it easy on the guy.
 

Baevus

the names ethan
Nov 4, 2012
565
47
Ok, sorry about the slack lately guys :l I'm starting work again as I got my new laptop. I'm adding a feature where you manually edit tabs from database and a panel where you can post news. That's just little of what yet is to come!
 

Baevus

the names ethan
Nov 4, 2012
565
47
BUMP!
I was just about to request a mod to re-open this thread.
Since it was never closed, I have to do this!
Project re-starting! Updating and improving :)

Next Update:
  • Profiles
  • Updated user-system
  • Ability to post news
 

Users who are viewing this thread

Top