This forum is in archive mode. You will not be able to post new content.

Author Topic: [PHP] My attempt to CMS  (Read 2923 times)

0 Members and 1 Guest are viewing this topic.

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
[PHP] My attempt to CMS
« on: May 20, 2011, 02:09:02 PM »
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)
Code: [Select]
<?php 
include 'core/page_content.php'
$content = new content;
eval(
"?>
".$content->template['template']."<?");
?>
core/page_content.php
Code: [Select]
<?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
Code: [Select]
<?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/
« Last Edit: May 23, 2011, 04:39:32 PM by Factionwars »
~Factionwars

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: [PHP] My attempt to CMS
« Reply #1 on: May 20, 2011, 03:03:38 PM »
Moved to web oriented programming, even tho this is kinda an example, its not a good enough/working not example to hit the code lib
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline Tsar

  • Peasant
  • *
  • Posts: 126
  • Cookies: 10
  • turing-recognizable
    • View Profile
Re: [PHP] My attempt to CMS
« Reply #2 on: May 20, 2011, 07:55:32 PM »
Interesting, you should set up a demo or explain how it works a little more though

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: [PHP] My attempt to CMS
« Reply #3 on: May 20, 2011, 07:58:08 PM »
Interesting, you should set up a demo or explain how it works a little more though
I am running a portfolio on it (i build it for that reason), so soon i will change content (it is a little bit to personal).
~Factionwars

Offline uNk

  • Knight
  • **
  • Posts: 197
  • Cookies: 9
    • View Profile
Re: [PHP] My attempt to CMS
« Reply #4 on: May 21, 2011, 07:26:49 PM »
Good job on this, could learn something from it and make it more advanced.

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: [PHP] My attempt to CMS
« Reply #5 on: May 23, 2011, 04:40:19 PM »
Added an working example, soon i will upload the database and how its all working.
I hope you guys got some feedback on it :D

(btw, design by me, so don't leech it :P)
with no permissions...
« Last Edit: May 23, 2011, 04:42:07 PM by Factionwars »
~Factionwars

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.