[DEV] SellIt [PHP / MySQLi]

Status
Not open for further replies.

Zeus

Active Member
Jun 30, 2012
150
30
0AQ1o.png

What is SellIt?
SellIt is an easy and manageable tool to sell your items online, such as emulators or CMS's. It will come with an easy way of editing your products with the dashboard and a nice, clean interface. And of course you can make your own templates with the easy system I am using, RainTPL

What are some features?
- RainTPL Template System
- Powerful PHP coding
- MySQLi Database Engine
- Easy-to-use original template
- Powerful dashboard

What are some snippets?
Some of the coding in the CMS is based upon LightCMS, please realise that I do NOT take credit for anyone else's work. I was merely inspired by Jontys work. The idea also came from Leon's client area. :)

config.php
PHP:
<?php
class Config {
// o-------------------------------------------------------o
// | Welcome to SellIt, an easy tool to sell your products |
// | without having to do everything yourself. Edit this  |
// | configuration file and your good to go.              |
// |-------------------------------------------------------|
// | Please read the documentation.txt file for more info  |
// o-------------------------------------------------------o
 
// MySQLi Configuration
private $host = '127.0.0.1';
private $username = 'root';
private $password = 'hello123';
private $database = 'sellit';
 
// Site Settings
public $siteUrl = 'http://localhost';
public $siteName = 'Easy Sell';
public $inMaint = false;
 
// Registration Settings
public $maxAccs = '1';
public $regEnabled = true;
 
// Control Settings
public $owner = 'Josh';
public $minDashRank = '9';
 
// o-------------------------------------------------------o
// | Please do not edit below unless you know what you are |
// | doing, it powers most of SellIt.                      |
// o-------------------------------------------------------o
 
// Define The Directories
private $rainDir = 'classes/rain/';
private $classesDir = 'classes/';
 
// Start Execute Function
public function execute() {
require $this->rainDir . 'class.php';
require $this->classesDir . 'users.php';
require $this->classesDir . 'core.php';
require $this->classesDir . 'hash.php';
require $this->classesDir . 'template.php';
require $this->classesDir . 'tickets.php';
$this->MySQLi['host'] = $this->host;
$this->MySQLi['username'] = $this->username;
$this->MySQLi['password'] = $this->password;
$this->MySQLi['database'] = $this->database;
}
 
}
?>

global.php
PHP:
<?php
// o-------------------------------------------------------o
// | Welcome to SellIt, an easy tool to sell your products |
// | without having to do everything yourself. Edit this  |
// | configuration file and your good to go.              |
// |-------------------------------------------------------|
// | Please read the documentation.txt file for more info  |
// o-------------------------------------------------------o
 
// Require The Config
require_once 'engine/config.php';
 
// Set Variables
$config = new Config;
 
// Start SellIt Engine
$config->execute();
 
// Set Class Variables
$core = new Core;
$users = new Users;
$hash = new Hash;
$tpl = new Template;
$tickets = new Tickets;
 
// Connect To Database
$db = @new MySQLi($config->MySQLi['host'], $config->MySQLi['username'], $config->MySQLi['password'], $config->MySQLi['database']);
 
// Check For Database Error
if (mysqli_connect_errno()) {
  $core->throwError(mysqli_connect_error());
}
 
// Check For Maintenance
if($config->inMaint == false && !defined('MAINT_PAGE')) {
if($users->getVar($users->username(), 'rank') >= '2') {
header('Location: /maintenance');
}
}
?>

Thanks
- Josh
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,456
I really like it to see other projects then only Habbo CMS's and stuff like that. Really original. Like it! Good luck with the development, it sounds great! ;)
 

Jian

Resident Weeb
Contributor
Sep 2, 2011
687
437
What happened to your other CMS? Lol.

OTP: Good luck! Original idea!
 

Zeus

Active Member
Jun 30, 2012
150
30
DevourCMS had extremely bad practices and it was really slow. I decided to discontinue it in the end, but this will be finished :)
 

Leon

Member
Jan 2, 2011
83
42
I slightly believe this's inspired by the client area I wrote. xD
 

Zeus

Active Member
Jun 30, 2012
150
30
Dashboard core has been started, just simply uses a GET system to include the files, if no files are found, it goes to 404.php

PHP:
<?php
// o-------------------------------------------------------o
// | This is the core for the dashboard, it controlls      |
// | and makes sure the dashboard works properly, please   |
// | do not edit this.                                     |
// o-------------------------------------------------------o
 
// Require global.php
require_once "../engine/classes/core.php";
require_once "../engine/classes/hash.php";
require_once "../engine/classes/tickets.php";
require_once "../engine/classes/users.php";
require_once "../engine/config.php";
 
// Set Variables
$core = new Core;
$hash = new Hash;
$tickets = new Tickets;
$users = new Users;
$config = new Config;
 
// Make Database Connection
$db = @new MySQLi($config->MySQLi['host'], $config->MySQLi['username'], $config->MySQLi['password'], $config->MySQLi['database']);
 
// Get System
if(isset($_GET["page"])) {
$pagesPath = "pages/";
$getFile = $db->real_escape_string($_GET["page"]);
if(file_exists($pagesPath . $getFile . ".php")) {
include $pagesPath . $getFile . ".php";
} else {
include $pagesPath . "404.php";
}
} else {
include "pages/home.php";
}
?>

Making lots of progress, have also been looking at the RainTPL stuff to get an idea of the templating i'll be using with caching etc.

Any suggestions, requests or ideas?
 

Zeus

Active Member
Jun 30, 2012
150
30
Looks nice, keep up the good work!
Cheers.

RainTPL has been implemented and it works perfectly. Also begun a template class which just contains a simple execute() function which will execute all the basic params. Might write up the documentation.txt before I go to the restaurant for some tea.
 

Zeus

Active Member
Jun 30, 2012
150
30
Lots and lots of updates!

Okay, so the updates today are visual updates, i've begun the theme and finished the index, working on getting the isset($_POST['var']) to work on the register page (i'm not sure why it wont work....) but here's what it looks like. Oh! and I decided to implement bootstrap for the buttons and navi etc ;D

Index;
eKAic.png


Register;
sgSNt.png


Also wrote up most of the documentation;
Code:
// o-------------------------------------------------------o
// | Please read the full documentation file. This file    |
// | includes many things about SellIt.                    |
// o-------------------------------------------------------o
// | Credits;                                              |
// | Josh Priestley, creator of SellIt                     |
// | Jonty, little code snippets and bases                 |
// | Leon, inspiration from his client area                |
// o-------------------------------------------------------o
 
// Part 1 - About SellIt
SellIt uses an easy template engine called RainTPL, and is adapted
through clean and fast coding. The CMS uses an easy database
engine which is known as MySQLi, which allows us to go to new 
extents with SellIt. If you have any questions regarding SellIt,
do not hesitate to contact me on Skype, joshua.luke.priestley
 
// Part 2 - Making A Template
Making templates are as easy as 1.. 2.. 3, all you need to know
is HTML and CSS with a touch of PHP and your good to go.
 
/ Step 1 - The Basics
The template system is easy to use. All it requires is making a
.php file in the index folder of your site, this file can be 
named anything. Now go into engine/template and create a .tpl
file, this is where you put all your HTML and CSS linkings. 
 
/ Step 2 - The PHP file
If you want to see the result of your template, in the .php
file you created earlier, write something like...
<?php
 
$tpl->draw('YOURFILENAME');
 
?>
Where it says 'YOURFILENAME' replace that with the .tpl file name
you created earlier, but do not add the .tpl part, for instance
if my file was called index.tpl, i'd just write index. Now your
finished! You can also use params which are below.
 
// Part 3 - Params
Params are easy to use and very efficient too. All you do is
assign them in your .php file and you can use them in your
tpl file linked to that PHP file. Detailed instructions are
below.
 
/ Step 1 - What It Does
So, you've created your template / edited a template and now
your wanting to use handy things called params which when
you write {$variable} it will call up some sort of text..
Like someone's username for instance.
 
/ Step 2 - Creating The Param
In order to do this, go into your PHP file which draws the
.tpl file you want to use your param in. Next, above the
$tpl->draw('filename'); part, write something along the
lines of, $tpl->assign('siteName', 'SellIt'); the first
variable, in this case, siteName is the text you use
to call the function, so i'd use {$siteName} in my .tpl
file and it would output 'SellIt'
 
/ Step 3 - Using Default Params
Default params can be used in any tpl file without having
to assign them to any php file. These default params
are listed below;
 
 
Thanks
- Josh
 

Zeus

Active Member
Jun 30, 2012
150
30
Amazing how fast you work!

I took alot of structuring from LightCMS to be completely honest, although all the classes are by me :D

Thanks Notak :]

Also, if anyone can figure out why my if(isset($_POST['var']) codes aren't working i'd be grateful:

PHP:
<?php
 
require_once "global.php";
 
define('regSelected', true);
if($users->LoggedIn()) {
header('Location: dashboard');
}
 
if(!$config->regEnabled) {
header('Location: /?regEnabled');
}
$tpl->assign('regError', null);
if(isset($_POST['email']) && isset($_POST['password'])) {
$email = $db->real_escape_string($_POST['email']);
$pass = $db->real_escape_string($_POST['password']);
$rpass = $db->real_escape_string($_POST['rpassword']);
$fname = $db->real_escape_string($_POST['fname']);
$lname = $db->real_escape_string($_POST['lname']);
 
if ($result = $db->query("SELECT * FROM `users` WHERE `email` = '".$email."'")) {
   if($result->num_rows == '0') {
if($rpass == $pass) {
$users->addUser($email, $hash->encrypt($pass), $fname, $lname);
  }
               } else { $tpl->assign('regError', '<div class="alert alert-error">Cannot register your account, check details and try again</div>'); }
} 
}
 
$tpl->assign('pageTitle', 'Register!');
$tpl->draw('header');
$tpl->draw('navi');
$tpl->draw('register');
?>
 

Zeus

Active Member
Jun 30, 2012
150
30
I finally figured out why my sessions weren't working, it was because I wasn't using session_start(), so now instead of cookies, logging in is handled by the $_SESSION variables. Register page is done but in-efficient, i'll either recode it before Version 1 BETA or re-code it after the beta. Going to do abit of work for 20 minutes then watch a movie :)
 

Zeus

Active Member
Jun 30, 2012
150
30
Okay, so recoded the register page, and begun the dash page, also added a few more tables into the database called products, this is where the products will be kept, so you can add new ones and also user_products where the user_id and product_id depend on whether that user has that particular service. Also made some RainTPL updates causing me not to be able to use the $db variable in my template files. I've also done a PHP downloader where if a user isn't logged in or doesn't have the permission to download the file their trying to download, they will be given a message. I'm going to have a rest now :p
 

iHarrison

Member
Mar 11, 2012
321
131
I took alot of structuring from LightCMS to be completely honest, although all the classes are by me :D

Thanks Notak :]

Also, if anyone can figure out why my if(isset($_POST['var']) codes aren't working i'd be grateful:

PHP:
<?php
 
require_once "global.php";
 
define('regSelected', true);
if($users->LoggedIn()) {
header('Location: dashboard');
}
 
if(!$config->regEnabled) {
header('Location: /?regEnabled');
}
$tpl->assign('regError', null);
if(isset($_POST['email']) && isset($_POST['password'])) {
$email = $db->real_escape_string($_POST['email']);
$pass = $db->real_escape_string($_POST['password']);
$rpass = $db->real_escape_string($_POST['rpassword']);
$fname = $db->real_escape_string($_POST['fname']);
$lname = $db->real_escape_string($_POST['lname']);
 
if ($result = $db->query("SELECT * FROM `users` WHERE `email` = '".$email."'")) {
  if($result->num_rows == '0') {
if($rpass == $pass) {
$users->addUser($email, $hash->encrypt($pass), $fname, $lname);
  }
              } else { $tpl->assign('regError', '<div class="alert alert-error">Cannot register your account, check details and try again</div>'); }
}
}
 
$tpl->assign('pageTitle', 'Register!');
$tpl->draw('header');
$tpl->draw('navi');
$tpl->draw('register');
?>

That indenting... I hope that's just because you pasted it into this post ;P
 
Status
Not open for further replies.

Users who are viewing this thread

Top