MojoCMS My First CMS

Status
Not open for further replies.

GarettM

Posting Freak
Aug 5, 2010
833
136
Hello Im A Newb :) Not a noob -_- im not that annoying

Well i wanted to test my Skill in codding So Im codding A CMS from scratch.. I Plan on adding basic authentication, because this is my first CMS the final outcome might be sloppy and full of exploits :/ WARNING: This is not a HABBO CMS this is a private CMS content management system i also hate habbo -_-

So Far Codded
Session Control
cookie Control
Template class
Authentication Class
Rank Class

Snippits:
updated:
Session Control for authentication:
PHP:
<?php
################################################
# Mojo - Created By GarettMcCarty
################################################
 
class session
{
    static $id;
    static $data = array();
 
    public function __construct()
    {
        $this->system_check();
    }
    public static function system_check()
    {
        if(!isset($_SESSION)):
        session_save_path('application\tmp');
        session_start();
        endif;
    }
    public static function check($id)
    {
        if(isset($_SESSION[$id])):
        Return True;
        else:
        Return False;
        endif;
    }
    public static function set_session($id, $data)
    {
        if(!static::check($id)):
          $_SESSION[$id] = $data;
        else:
          Return False;
        endif;
    }
    public static function forget($id)
    {
        if(static::check($id)):
          unset($_SESSION[$id]);
        endif;
    }
}
 
?>
authentication :
PHP:
<?php
################################################
# Mojo - Created By GarettMcCarty
################################################
 
class accounts {
 
    public static function status()
    {
        global $sessions;
        if($sessions->check('username') or $sessions->check('userid')):
        Return True;
        else:
        Return False;
        endif;
    }
    public static function information($name)
    {
        global $database, $validate;
        $query  = $database::query("SELECT * FROM accounts WHERE username='".$_SESSION['username']."' LIMIT 1");
        $result = $database::sql_array($query);
     
        return $result[$name];
    }
    public static function login()
    {
        global $database, $validate, $sessions, $cookie;
        $username = $database::escape($_POST['m_username']);
        $password = sha1($_POST['m_password']);
 
     
        if($validate::email($username))
        {
          $query = $database::query("SELECT * FROM accounts WHERE email='".$username."' LIMIT 1");
          $result = $database::sql_array($query);
       
          if($database::sql_count($query) > 0)
          {
              if($result['password'] == $password)
              {
                $sessions::set_session('username', $result['username']);
                $sessions::set_session('userid', $result['id']);
                header("Location: me.php");
              } else {
                  print "Wrong Password";
              }
          } else {
                print "Email was not found";
          }
       
        } else {
         
            $query  = $database::query("SELECT * FROM accounts WHERE username='".$username."' LIMIT 1");
            $result = $database::sql_array($query);
         
            if($database::sql_count($query) > 0)
            {
                if($result['password'] == $password)
                {
                    $sessions::set_session('username', $username);
                    $sessions::set_session('userid', $result['id']);
                    header("Location: me.php"); 
                } else {
                    print "Wrong Password";
                }
            } else {
                print "Username was not found";
            }
        }
    }
 
    public static function register()
    {
     
    }
 
}
 
 
 
 
 
?>

Notes:
Still haven't found away to return a error like $error :S but ill keep trying
So far you can log in by username or email, Users language is set when logged in sadley u cant change ur language un less you goto account settings and change it threw db UPDATE lol :) first CMS YAY and thanks for the negative comments ^_^
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
The fact you can't even spell 'coding' really makes me question my faith in this development.. but whatever, good luck.

Screenshots and/or code snippets must be posted soon or I will close the thread.
 

Extreme

Member
Aug 21, 2012
60
8
Got a point. A guy that claims he code's a cms and cant spell coding doesn't look that good to me. ScreenShots please.
 

GarettM

Posting Freak
Aug 5, 2010
833
136
Updates:
Administration check:

PHP:
<?php
################################################
# Mojo - Created By GarettMcCarty
################################################
 
class fuserights {
 
    public static function is_staff()
    {
        global $accounts;
        if($accounts::status() == TRUE)
        {
            if($accounts::information('is_moderator') > 0)
            {
                return true;
            }
          Return False;
        }
      Return False;
    }
}
 
 
 
?>

The fact you can't even spell 'coding' really makes me question my faith in this development.. but whatever, good luck.

Screenshots and/or code snippets must be posted soon or I will close the thread.
Like i said i had to register for school then id post snippets of the code if ud prefer i can set up a github account and post the hole code so far on there i dont mind showing my work i just will worn code isnt complete and will not work 100%
 

GarettM

Posting Freak
Aug 5, 2010
833
136
Yeah you need static for ::, though I always use ->, I've never looked up the benefits of either, but I think using non-static is better for most things.
really? Im just use to static function and alot of times my php version doesnt allow -> or easyPHP doesn't my hope is that this cms can be used with little to none errors 
Update:
Working On Registration and Design so far only one error with registration :)
PHP:
<?php
################################################
# Mojo - Created By GarettMcCarty
################################################
 
class accounts {
   
    public static function status()
    {
        global $sessions;
        if($sessions->check('username') or $sessions->check('userid')):
        Return True;
        else:
        Return False;
        endif; 
    }
    public static function information($name)
    {
        global $database, $validate;
        $query  = $database::query("SELECT * FROM accounts WHERE username='".$_SESSION['username']."' LIMIT 1");
        $result = $database::sql_array($query);
       
        return $result[$name];
    }
    public static function login()
    {
        global $database, $validate, $sessions, $cookie;
        $username = $database::escape($_POST['m_username']);
        $password = sha1($_POST['m_password']);
 
       
        if($validate::email($username))
        {
          $query = $database::query("SELECT * FROM accounts WHERE email='".$username."' LIMIT 1");
          $result = $database::sql_array($query);
         
          if($database::sql_count($query) > 0)
          {
              if($result['password'] == $password)
              {
                $sessions::set_session('username', $result['username']);
                $sessions::set_session('userid', $result['id']);
                header("Location: me.php");
              } else {
                  print "Wrong Password";
              }
          } else {
                print "Email was not found";
          }
         
        } else {
           
            $query  = $database::query("SELECT * FROM accounts WHERE username='".$username."' LIMIT 1");
            $result = $database::sql_array($query);
           
            if($database::sql_count($query) > 0)
            {
                if($result['password'] == $password)
                {
                    $sessions::set_session('username', $username);
                    $sessions::set_session('userid', $result['id']);
                    header("Location: me.php");   
                } else {
                    print "Wrong Password";
                }
            } else {
                print "Username was not found";
            }
        }
    }
   
    public static function register()
    {
        global $sessions, $database, $validate;
        $username = $database::escape($_POST['m_username']);
        $realname = $database::escape($_POST['m_realname']);
        $email    = $database::escape($_POST['m_email']);
        $password = sha1($_POST['m_password']);
        $vpassowrd= sha1($_POST['m_vpassword']);
        $language = $_POST['m_language'];
       
        $query = $database::query("SELECT * FROM accounts WHERE username='".$username."',email='".$email."' LIMIT 1");
       
        if($validate::email($email))
        {
            if($password == $vpassowrd)
            {
                if($database::sql_count($query) <= 0)
                {
                    header("Locatiom: me.php");
                    $_SESSION['username'] = $username;
                    return $database::query("INSERT INTO `accounts` ( `id` ,`username` ,`realname` ,`email` ,`password` ,`created_on` ,`updated_on` ,`credits` ,`points` ,`is_moderator` ,`language` ,`is_banned`) VALUES ( NULL ,  '".$username."',  '".$realname."',  '".$email."',  '".$password."',  '".date('Y,m,d H:i,s')."',  '".date('Y,m,d H:i,s')."',  '0',  '20',  '0',  '".$language."',  '0');");
                } else {
                    print "Username Tooken";
                }
            } else {
                print "Passwords Didnt Match";
            }
           
        } else {
            print "Not Valid Email";
        }
 
    }
 
}
 
 
 
 
 
?>

More:
- Setting Up GitHub Account / repo for This project
- Working on Graphics and CMS design :( I Hate Designing -_-
- Login With Email or Username sha1 password about to change it to md5
 

Siract

Classic Habbo
Sep 4, 2011
148
27
I'm sorry, a bit groggy today not paying much attention to people. If you want to do something just stick at it and you will get better trust me.
 

GarettM

Posting Freak
Aug 5, 2010
833
136
UPDATE:
- Users have account images ;)
- Started Design ( IK i suck at css so please dont judge )
IMG of user.php
mojo_screenie.png
 

GarettM

Posting Freak
Aug 5, 2010
833
136
better desgin them what i can do.
Doesn't Matter i Gotta Scrap the Hole Design anyways i forgot my main goal and started on something unnecessary
Update Moved That Little area with user picture to the left all the way and got rid of the top left radius to make it look more professional also added some icons ex: alert icon + New Alert, message icon + New Message
 
Status
Not open for further replies.

Users who are viewing this thread

Top