Hi, i created this system a month ago, still working on it.
Use it if you like, or help me built more.
Blackfact.php (main page)
<?php
include 'core/page_content.php';
$content = new content;
eval("?>".$content->template['template']."<?");
?>
core/page_content.php
<?php
/* Created by Factionwars
* You are free to use and edit it for home usage only
* Soon a admin panel will be attached to the cms.
*/
class content {
//Define area
// Edit from here
//MySQL
Private $host = "localhost";
Private $user_name = "MySQL_username";
Private $user_password = "MySQL_pass";
Private $user_database = "MySQL_db";
//Faction_Blog
Public $site;
Public $page;
Public $result_content;
Public $result_design;
Public $result_navi;
Public $site_name1 = "factionwars";
Public $site_name2 = "blackstar";
public $site_name3 = "index";
Public $template;
// CMS configuration
Private $debug_enabled = false;
// To here
Private $result_module;
// Constructs the page when the object is intialized
function __construct() {
//Get the enabled module from db
$this->load_module();
//Includes the current module
include $this->result_module['location'];
//Creating a new object for the module
$buildpage = new buildPage();
//Staticly ordering the module to build the page
$buildpage::build();
}
private function load_module()
{
// Gets the current enabled module from the database.
$this->result_module = $this->mysql_get("modules", "location", "enabled", "true");
}
// Example usage of the mysql_get function, we select all columns from a table where user is admin
// ("Table1", "", "user", "admin")
// Now we select the ip column from table1 where user is admin and id is 1
// ("Table1", "ip", "user", "admin", "id", "1")
public function mysql_get($table, $column = "", $where = "", $statement = "", $where2 = "", $statement2 = "") {
$connection = mysql_connect($this->host, $this->user_name, $this->user_password);
if(!$connection) {
if($this->debug_enabled == true){echo mysql_error();}
else {$this->errorpage();}
}
mysql_select_db($this->user_database);
if(!$where == "") {
if(!$where2 == "") {
if(!$column == ""){
$sql = "SELECT ".$column." FROM ".$table." WHERE ".$where."='".$statement."' AND ".$where2."='".$statement2."'";
}
else
{
$sql = "SELECT * FROM ".$table." WHERE ".$where."='".$statement."' AND ".$where2."='".$statement2."'";
}
}
else if(!$column == ""){
$sql = "SELECT ".$column." FROM ".$table." WHERE ".$where."='".$statement."'";
}
else
{
$sql = "SELECT * FROM ".$table." WHERE ".$where."='".$statement."'";
}
}
else
{
if(!$column == "")
{
$sql = "SELECT ".$column." FROM ".$table."";
}
else
{
$sql = "SELECT * FROM ".$table."";
}
}
$result = mysql_query($sql);
$connection = mysql_close();
if(!$result)
{
if($this->debug_enabled == true){echo mysql_error();}
else{$this->errorpage();}
}
return mysql_fetch_assoc($result);
}
public function errorpage()
{
//Stil not done.
echo "An error has occurd.";
}
}
?>
Modules/faction_blog.php
<?php
/* Created by Factionwars
* You are free to use and edit it for home usage only
* Soon a admin panel will be attached to the cms.
*/
class buildPage {
public function build() {
//User input
$this->site = strtolower(strip_tags($_GET["aka"]));
$this->page = strtolower(strip_tags($_GET["sub"]));
if ($this->page == "") { $this->page = "home"; }
if ($this->site == $this->site_name2) {
// loading template
$this->template = $this->mysql_get("fblog_template", "template", "id", "1");
$this->result_design = $this->mysql_get("design", "", "page", $this->site_name2);
$this->result_navi = $this->mysql_get("navi", "", "page", $this->site_name2);
if (in_array($this->page, $this->result_navi)){
$this->result_content = $this->mysql_get("fblog_content", "content", "page", $this->page, "id", "2");
}
}
//Load the design
else if ($this->site == $this->site_name1) {
// loading template
$this->template = $this->mysql_get("fblog_template", "template", "id", "1");
//load the css styles
$this->result_design = $this->mysql_get("design", "", "page", $this->site_name1);
// load the navigation menu
$this->result_navi = $this->mysql_get("navi", "", "page", $this->site_name1);
//Load the content for the mid container
if (in_array($this->page,$this->result_navi)){
$this->result_content = $this->mysql_get("fblog_content", "content", "page", $this->page, "id", "1");
}
}
else {
// loading template
$this->template = $this->mysql_get("fblog_template", "template", "id", "2");
}
}
}
?>
Feel free to post ideas\comments
*todo*
Admin panel,
More flexibility
Error handler.
and more..
EDIT: Added some explainable for the core, more is coming. Working example, (i cleaned content cusz of privacy) http://blackfact.nl/