diff --git a/admin/class/Colors.php b/admin/class/Colors.php index 4796e4af..a056afa5 100755 --- a/admin/class/Colors.php +++ b/admin/class/Colors.php @@ -5,9 +5,10 @@ class Colors{ private $conn; private $table_name = "color"; - + public $id; public $color; + public $prx; // constructor public function __construct($db){ @@ -19,7 +20,7 @@ function create(){ // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET color = :color"; @@ -46,7 +47,7 @@ function create(){ function update(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET color = :color WHERE @@ -82,7 +83,7 @@ function showAll(){ $query = "SELECT id, color FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " ORDER BY color"; @@ -98,7 +99,7 @@ function showAllList(){ $query = "SELECT id, color FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " ORDER BY color"; @@ -110,7 +111,7 @@ function showAllList(){ public function countAll(){ - $query = "SELECT id FROM color"; + $query = "SELECT id FROM ".$this->prx."color"; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -122,7 +123,7 @@ public function countAll(){ function showById(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE id = ? LIMIT 0,1"; @@ -143,7 +144,7 @@ function colorExists(){ // query to check if email exists $query = "SELECT id, color - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE color = ? LIMIT 0,1"; @@ -183,7 +184,7 @@ function colorExists(){ // delete the role function delete(){ - $query = "DELETE FROM " . $this->table_name . " WHERE id = ?"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE id = ?"; $stmt = $this->conn->prepare($query); $stmt->bindParam(1, $this->id); diff --git a/admin/class/Contact.php b/admin/class/Contact.php index db960a49..73e1f299 100755 --- a/admin/class/Contact.php +++ b/admin/class/Contact.php @@ -9,6 +9,7 @@ class Contact{ public $id; public $label; public $email; + public $prx; // constructor public function __construct($db){ @@ -20,7 +21,7 @@ function create(){ // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET label = :label, email = :email"; @@ -51,7 +52,7 @@ function update(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET email = :email WHERE @@ -88,7 +89,7 @@ function showAll(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " ORDER BY id"; @@ -104,7 +105,7 @@ function showAllContacts(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE NOT id=1 ORDER BY id"; @@ -117,7 +118,7 @@ function showAllContacts(){ function delete(){ - $query = "DELETE FROM " . $this->table_name . " WHERE id = :id"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE id = :id"; $stmt = $this->conn->prepare($query); $stmt->bindParam(":id", $this->id); diff --git a/admin/class/File.php b/admin/class/File.php index 46b23876..65e22b2a 100755 --- a/admin/class/File.php +++ b/admin/class/File.php @@ -13,6 +13,7 @@ class File{ public $rolename; public $file; public $operation; + public $prx; // constructor public function __construct($db){ @@ -71,13 +72,13 @@ function uploadFile(){ $query=""; if($this->operation=="add"){ $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET filename = :filename, title = :title"; }else if($this->operation=="edit"){ $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET filename = :filename, title = :title @@ -239,7 +240,7 @@ function showError($stmt){ function update(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET title = :title WHERE @@ -268,7 +269,7 @@ function update(){ // delete the file function delete(){ - $query = "DELETE FROM " . $this->table_name . " WHERE id = ?"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE id = ?"; $stmt = $this->conn->prepare($query); $stmt->bindParam(1, $this->id); @@ -283,7 +284,7 @@ function delete(){ function showById(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE id = ? LIMIT 0,1"; diff --git a/admin/class/Home.php b/admin/class/Home.php index 023c162e..2d75bb84 100755 --- a/admin/class/Home.php +++ b/admin/class/Home.php @@ -8,6 +8,7 @@ class Home{ public $id; public $name_function; + public $prx; // constructor @@ -19,7 +20,7 @@ public function __construct($db){ function create(){ // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET name_function = :name_function"; @@ -55,7 +56,7 @@ function showAll(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " ORDER BY id"; @@ -69,7 +70,7 @@ function showAll(){ function delete(){ - $query = "DELETE FROM " . $this->table_name . " WHERE name_function = :name_function"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE name_function = :name_function"; $stmt = $this->conn->prepare($query); $stmt->bindParam(':name_function', $this->name_function); diff --git a/admin/class/Menu.php b/admin/class/Menu.php index bfda0a05..473c6ec7 100755 --- a/admin/class/Menu.php +++ b/admin/class/Menu.php @@ -13,6 +13,7 @@ class Menu{ public $itemorder; public $parent; public $childof; + public $prx; // constructor public function __construct($db){ @@ -21,7 +22,7 @@ public function __construct($db){ // create new role record function insert(){ - $query="INSERT INTO menu SET pagename = :page_name"; + $query="INSERT INTO ".$this->prx."menu SET pagename = :page_name"; $stmt = $this->conn->prepare($query); $stmt->bindParam(':page_name', $this->pagename); if($stmt->execute()){ @@ -42,7 +43,7 @@ function showError($stmt){ function update(){ $query = "UPDATE - " . $this->table_name . " + " .$this->prx.$this->table_name . " SET inmenu = :inmenu, itemorder = :itemorder, @@ -83,7 +84,7 @@ function showAll(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " ORDER BY itemorder"; @@ -98,7 +99,7 @@ function showAllParent(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE parent = 1 AND inmenu = 1 ORDER BY @@ -114,7 +115,7 @@ function showOrder(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE id = :id"; @@ -130,7 +131,7 @@ function showAllChildInMenu(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE childof = :childof AND inmenu = 1 AND parent = 0 ORDER BY @@ -147,7 +148,7 @@ function showAllChildNone(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE childof = 'none' AND inmenu = 1 AND parent = 0 ORDER BY @@ -165,7 +166,7 @@ public function countChild(){ $query = "SELECT id FROM - menu + ".$this->prx."menu WHERE childof = :childof"; $stmt = $this->conn->prepare( $query ); @@ -184,7 +185,7 @@ public function countChildInMenu(){ $query = "SELECT id FROM - menu + ".$this->prx."menu WHERE childof = :childof and inmenu = 1"; $stmt = $this->conn->prepare( $query ); @@ -204,7 +205,7 @@ function showAllNotInMenu(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE inmenu = 0 ORDER BY @@ -226,7 +227,7 @@ function showMenu(){ $query = "SELECT * FROM - menu + ".$this->prx."menu WHERE inmenu = 1 ORDER BY itemorder ASC"; @@ -239,7 +240,7 @@ function showMenu(){ public function countAll(){ - $query = "SELECT id FROM menu"; + $query = "SELECT id FROM ".$this->prx."menu"; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -251,7 +252,7 @@ public function countAll(){ function showById(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE id = ? LIMIT 0,1"; @@ -272,7 +273,7 @@ function showById(){ function showByName(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE pagename = :pagename LIMIT 0,1"; @@ -298,7 +299,7 @@ function showByName(){ function delete(){ - $query = "DELETE FROM menu WHERE pagename = :pagename"; + $query = "DELETE FROM ".$this->prx."menu WHERE pagename = :pagename"; $stmt = $this->conn->prepare($query); $stmt->bindParam(":pagename",$this->pagename); diff --git a/admin/class/Page.php b/admin/class/Page.php index e2854415..4992e7f9 100755 --- a/admin/class/Page.php +++ b/admin/class/Page.php @@ -34,6 +34,7 @@ class Page{ public $child_of; public $maps; public $contacts; + public $prx; // constructor public function __construct($db){ @@ -278,15 +279,15 @@ function destroyCheckSessVar(){ function insert(){ - if($this->type=="default"){ - $this->table="default_page"; - }else if($this->type=="custom"){ - $this->table="page"; - } + // if($this->type=="default"){ + // $this->table="default_page"; + // }else if($this->type=="custom"){ + // $this->table="page"; + // } // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET page_name = :page_name, no_mod = :no_mod, @@ -314,7 +315,7 @@ function insert(){ if($this->visual_img==1){ $this->uploadPhoto(); }else if($this->visual_gall==1){ - $query2 = "UPDATE " . $this->table . " + $query2 = "UPDATE " .$this->prx. $this->table_name . " SET img = :img WHERE page_name = :page_name"; @@ -328,7 +329,7 @@ function insert(){ $stmt2->execute(); } - $query1="INSERT INTO menu SET pagename = :page_name"; + $query1="INSERT INTO ".$this->prx."menu SET pagename = :page_name"; $stmt1 = $this->conn->prepare($query1); $stmt1->bindParam(':page_name', $this->page_name); if($stmt1->execute()){ @@ -365,7 +366,7 @@ function update(){ $stmt=""; $query = "UPDATE - " . $this->table . " + " .$this->prx. $this->table . " SET page_name = :page_name".$this->setNo_mod.", layout = :layout, @@ -394,7 +395,7 @@ function update(){ $query = "UPDATE - default_page + ".$this->prx."default_page SET header = :header, use_name = :use_name, @@ -410,7 +411,7 @@ function update(){ $stmt->bindParam(':id', $this->id); if($stmt->execute()){ - $query1="SELECT * FROM ".$this->table." WHERE page_name = :page_name LIMIT 0,1"; + $query1="SELECT * FROM ".$this->prx.$this->table." WHERE page_name = :page_name LIMIT 0,1"; $stmt1 = $this->conn->prepare($query1); $stmt1->bindParam(':page_name', $this->page_name); $stmt1->execute(); @@ -427,7 +428,7 @@ function update(){ return false; } }else if($this->visual_gall==1){ - $query2 = "UPDATE " . $this->table . " + $query2 = "UPDATE " .$this->prx. $this->table . " SET img = :img WHERE page_name = :page_name"; @@ -458,7 +459,7 @@ function update(){ if($stmt->execute()){ if($this->old_page_name != $this->page_name){ - $query3="SELECT * FROM menu WHERE pagename = :page_name LIMIT 0,1"; + $query3="SELECT * FROM ".$this->prx."menu WHERE pagename = :page_name LIMIT 0,1"; $stmt3 = $this->conn->prepare($query3); $stmt3->bindParam(':page_name', $this->old_page_name); $stmt3->execute(); @@ -466,7 +467,7 @@ function update(){ $id=$row3['id']; - $query2 = "UPDATE menu SET + $query2 = "UPDATE ".$this->prx."menu SET pagename = :page_name WHERE id = :id"; @@ -495,7 +496,7 @@ function update(){ - $query1="SELECT * FROM ".$this->table." WHERE page_name = :page_name LIMIT 0,1"; + $query1="SELECT * FROM ".$this->prx.$this->table." WHERE page_name = :page_name LIMIT 0,1"; $stmt1 = $this->conn->prepare($query1); $stmt1->bindParam(':page_name', $this->page_name); $stmt1->execute(); @@ -512,7 +513,7 @@ function update(){ return false; } }else if($this->visual_gall==1){ - $query2 = "UPDATE " . $this->table . " + $query2 = "UPDATE " .$this->prx. $this->table . " SET img = :img WHERE page_name = :page_name"; @@ -607,7 +608,7 @@ function uploadPhoto(){ } } } - $query2 = "UPDATE " . $this->table . " + $query2 = "UPDATE " .$this->prx. $this->table . " SET img = :img WHERE page_name = :page_name"; @@ -739,7 +740,7 @@ function showAllCustom($from_record_num, $records_per_page,$where){ $query = "SELECT * FROM - " . $this->table_name . "".$where." + " .$this->prx. $this->table_name . "".$where." ORDER BY id DESC LIMIT @@ -758,7 +759,7 @@ function showAllDefault(){ $query = "SELECT * FROM - default_page + ".$this->prx."default_page ORDER BY id ASC"; @@ -773,7 +774,7 @@ function showAllPages(){ $query = "SELECT * FROM - page + ".$this->prx."page ORDER BY id DESC"; @@ -788,7 +789,7 @@ function showAllPages(){ $query1 = "SELECT * FROM - default_page + ".$this->prx."default_page ORDER BY id DESC"; @@ -808,7 +809,7 @@ function showMenu(){ $query = "SELECT * FROM - menu + ".$this->prx."menu WHERE inmenu = 'y' ORDER BY itemorder ASC"; @@ -821,7 +822,7 @@ function showMenu(){ public function countAllDefault(){ - $query = "SELECT id FROM default_page"; + $query = "SELECT id FROM ".$this->prx."default_page"; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -833,7 +834,7 @@ public function countAllDefault(){ public function countAllCustom(){ - $query = "SELECT id FROM page"; + $query = "SELECT id FROM ".$this->prx."page"; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -845,7 +846,7 @@ public function countAllCustom(){ public function countFetchCustom($where){ - $query = "SELECT id FROM page".$where.""; + $query = "SELECT id FROM ".$this->prx."page".$where.""; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -858,7 +859,7 @@ public function countFetchCustom($where){ function showById(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE id = ? LIMIT 0,1"; @@ -882,7 +883,7 @@ function showById(){ function showByName(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE page_name = :page_name LIMIT 0,1"; @@ -905,7 +906,7 @@ function showByName(){ function showByIdDefault(){ $query = "SELECT * - FROM default_page + FROM ".$this->prx."default_page WHERE id = ? LIMIT 0,1"; @@ -927,7 +928,7 @@ function showByIdDefault(){ function showByNameDefault(){ $query = "SELECT * - FROM default_page + FROM ".$this->prx."default_page WHERE page_name = :page_name LIMIT 0,1"; @@ -964,13 +965,13 @@ function delete(){ $name=$this->page_name; - $query = "DELETE FROM " . $this->table_name . " WHERE id = ?"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE id = ?"; $stmt = $this->conn->prepare($query); $stmt->bindParam(1, $this->id); if($stmt->execute()){ - $query1 = "DELETE FROM menu WHERE pagename = :pagename"; + $query1 = "DELETE FROM ".$this->prx."menu WHERE pagename = :pagename"; $stmt1 = $this->conn->prepare($query1); $stmt1->bindParam(":pagename", $name); diff --git a/admin/class/Plugins.php b/admin/class/Plugins.php index e7b614e4..a983ee70 100755 --- a/admin/class/Plugins.php +++ b/admin/class/Plugins.php @@ -19,6 +19,7 @@ class Plugins{ public $sub_add_title; public $sub_add_link; public $active; + public $prx; // constructor public function __construct($db){ @@ -30,7 +31,7 @@ function create(){ // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET plugin_name = :plugin_name, link = :link, @@ -78,7 +79,7 @@ function updateActive(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET active = :active WHERE @@ -94,7 +95,7 @@ function updateActive(){ // execute the query, also check if query was successful if($stmt->execute()){ if($this->active==1 && $this->page_exist>0){ - $query1= "INSERT INTO default_page + $query1= "INSERT INTO ".$this->prx."default_page SET page_name = :page_name, header = 1, @@ -139,7 +140,7 @@ function showAll(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " ORDER BY id"; @@ -151,7 +152,7 @@ function showAll(){ function showByName(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE plugin_name = :plugin_name LIMIT 0,1"; @@ -178,7 +179,7 @@ function showByName(){ function delete(){ - $query = "DELETE FROM " . $this->table_name . " WHERE plugin_name = :plugin_name"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE plugin_name = :plugin_name"; $stmt = $this->conn->prepare($query); $stmt->bindParam(':plugin_name', $this->plugin_name); @@ -192,7 +193,7 @@ function delete(){ function deletePage(){ - $query = "DELETE FROM default_page WHERE page_name = :plugin_name"; + $query = "DELETE FROM ".$this->prx."default_page WHERE page_name = :plugin_name"; $stmt = $this->conn->prepare($query); $stmt->bindParam(':plugin_name', $this->plugin_name); diff --git a/admin/class/Role.php b/admin/class/Role.php index 0cb3b27b..a5e81c9b 100755 --- a/admin/class/Role.php +++ b/admin/class/Role.php @@ -19,7 +19,7 @@ function create(){ // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET rolename = :rolename"; @@ -54,7 +54,7 @@ function showAll($from_record_num,$records_per_page){ $query = "SELECT id, rolename FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE NOT rolename='Admin' ORDER BY @@ -73,7 +73,7 @@ function showAllList(){ $query = "SELECT id, rolename FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE NOT rolename='Admin' ORDER BY @@ -87,7 +87,7 @@ function showAllList(){ public function countAll(){ - $query = "SELECT id FROM roles"; + $query = "SELECT id FROM ".$this->prx."roles"; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -101,7 +101,7 @@ function roleExists(){ // query to check if email exists $query = "SELECT id, rolename - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE rolename = ? LIMIT 0,1"; @@ -141,7 +141,7 @@ function roleExists(){ // delete the role function delete(){ - $query = "DELETE FROM " . $this->table_name . " WHERE id = ?"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE id = ?"; $stmt = $this->conn->prepare($query); $stmt->bindParam(1, $this->id); @@ -153,41 +153,6 @@ function delete(){ } } - - // function showById($id){ - - // //select all data - // $query = "SELECT - // rolename - // FROM - // " . $this->table_name . " - // WHERE - // id = ".$id.""; - - // $stmt = $this->conn->prepare( $query ); - - // $stmt->execute(); - // return $stmt; - - // } - - // function rolename_id(){ - // //select all data - // $query = "SELECT - // id, rolename - // FROM - // " . $this->table_name . " - // WHERE - // rolename = :rolename"; - - // $stmt = $this->conn->prepare( $query ); - // $stmt->execute(); - - // return $stmt; - // } - - - } ?> \ No newline at end of file diff --git a/admin/class/Settings.php b/admin/class/Settings.php index a818d351..2230df3d 100755 --- a/admin/class/Settings.php +++ b/admin/class/Settings.php @@ -1,5 +1,4 @@ conn = $db; @@ -23,7 +25,7 @@ public function __construct($db){ function update(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET site_name = :site_name, site_description = :site_description, @@ -61,7 +63,7 @@ function update(){ function updateTheme(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET theme = :theme"; // prepare the query @@ -95,7 +97,7 @@ function showSettings(){ $query = "SELECT * FROM - " . $this->table_name . ""; + " .$this->prx. $this->table_name . ""; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -106,7 +108,7 @@ function showSettings(){ function updateCheck(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET dm = :dm WHERE @@ -136,7 +138,7 @@ function showLangAndName(){ $query = "SELECT * FROM - " . $this->table_name . ""; + " .$this->prx. $this->table_name . ""; $stmt = $this->conn->prepare( $query ); $stmt->execute(); diff --git a/admin/class/User.php b/admin/class/User.php index e5281249..cb37e336 100755 --- a/admin/class/User.php +++ b/admin/class/User.php @@ -14,6 +14,7 @@ class User{ public $last_login; public $token; public $expDate; + public $prx; // constructor public function __construct($db){ @@ -25,7 +26,7 @@ function create(){ // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET username = :username, password = :password, @@ -65,7 +66,7 @@ function update(){ } // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET username = :username, email = :email" . $this->setRolename . " @@ -97,7 +98,7 @@ function update(){ function updatePass(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET password = :password WHERE @@ -124,7 +125,7 @@ function updatePass(){ function updateLog($time){ $query="UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET last_login=:last_login WHERE username = :username"; @@ -146,7 +147,7 @@ function updateLog($time){ public function findToken(){ - $query = "SELECT * FROM password_reset_temp WHERE + $query = "SELECT * FROM ".$this->prx."password_reset_temp WHERE ( email = :email AND token = :token)"; $stmt = $this->conn->prepare( $query ); @@ -168,7 +169,7 @@ function showAll($from_record_num, $records_per_page, $where){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " WHERE NOT rolename='Admin'".$where." ORDER BY @@ -184,7 +185,7 @@ function showAll($from_record_num, $records_per_page, $where){ function showById(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE id = ? LIMIT 0,1"; @@ -203,7 +204,7 @@ function showById(){ function showByEmail(){ $query = "SELECT * - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE email = :email LIMIT 0,1"; @@ -222,7 +223,7 @@ function showByEmail(){ function showEmailPass(){ $query = "SELECT * - FROM password_reset_temp + FROM ".$this->prx."password_reset_temp WHERE email = :email LIMIT 0,1"; @@ -239,7 +240,7 @@ function showEmailPass(){ public function countAll(){ - $query = "SELECT id FROM accounts WHERE NOT id=1"; + $query = "SELECT id FROM ".$this->prx."accounts WHERE NOT id=1"; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -251,7 +252,7 @@ public function countAll(){ public function countFetch($where){ - $query = "SELECT id FROM accounts WHERE NOT id=1 ".$where.""; + $query = "SELECT id FROM ".$this->prx."accounts WHERE NOT id=1 ".$where.""; $stmt = $this->conn->prepare( $query ); $stmt->execute(); @@ -267,7 +268,7 @@ function emailExists(){ // query to check if email exists $query = "SELECT id, username, password, rolename - FROM " . $this->table_name . " + FROM " .$this->prx. $this->table_name . " WHERE email = ? LIMIT 0,1"; @@ -308,7 +309,7 @@ function emailExists(){ function delete(){ - $query = "DELETE FROM " . $this->table_name . " WHERE id = ?"; + $query = "DELETE FROM " .$this->prx. $this->table_name . " WHERE id = ?"; $stmt = $this->conn->prepare($query); $stmt->bindParam(1, $this->id); diff --git a/admin/class/Verify.php b/admin/class/Verify.php index 97288e90..aed32115 100755 --- a/admin/class/Verify.php +++ b/admin/class/Verify.php @@ -9,6 +9,7 @@ class Verify{ public $id; public $public; public $secret; + public $prx; // constructor public function __construct($db){ @@ -20,7 +21,7 @@ function create(){ // insert query $query = "INSERT INTO - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET public = :public, secret = :secret"; @@ -47,7 +48,7 @@ function create(){ function update(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET public = :public, secret = :secret, @@ -78,7 +79,7 @@ function update(){ function updateActive(){ // insert query $query = "UPDATE - " . $this->table_name . " + " .$this->prx. $this->table_name . " SET active = :active WHERE @@ -115,7 +116,7 @@ function showAll(){ $query = "SELECT * FROM - " . $this->table_name . " + " .$this->prx. $this->table_name . " ORDER BY id"; @@ -126,109 +127,6 @@ function showAll(){ } - // function showAllList(){ - // //select all data - // $query = "SELECT - // id, color - // FROM - // " . $this->table_name . " - // ORDER BY - // color"; - - // $stmt = $this->conn->prepare( $query ); - // $stmt->execute(); - - // return $stmt; - // } - - // public function countAll(){ - - // $query = "SELECT id FROM color"; - - // $stmt = $this->conn->prepare( $query ); - // $stmt->execute(); - - // $num = $stmt->rowCount(); - - // return $num; - // } - -// function showById(){ -// $query = "SELECT * -// FROM " . $this->table_name . " -// WHERE id = ? -// LIMIT 0,1"; - -// $stmt = $this->conn->prepare( $query ); -// $stmt->bindParam(1, $this->id); -// $stmt->execute(); - -// $row = $stmt->fetch(PDO::FETCH_ASSOC); - -// $this->id = $row['id']; -// $this->username = $row['username']; -// $this->email = $row['email']; -// $this->rolename = $row['rolename']; -// } - - -// function colorExists(){ - -// // query to check if email exists -// $query = "SELECT id, color -// FROM " . $this->table_name . " -// WHERE color = ? -// LIMIT 0,1"; - -// // prepare the query -// $stmt = $this->conn->prepare( $query ); - -// // sanitize -// $this->color=htmlspecialchars(strip_tags($this->color)); - -// // bind given email value -// $stmt->bindParam(1, $this->color); - -// // execute the query -// $stmt->execute(); - -// // get number of rows -// $num = $stmt->rowCount(); - -// // if email exists, assign values to object properties for easy access and use for php sessions -// if($num>0){ - -// // get record details / values -// $row = $stmt->fetch(PDO::FETCH_ASSOC); - -// // assign values to object properties -// $this->id = $row['id']; -// $this->status = $row['color']; - -// // return true because email exists in the database -// return true; -// } - -// // return false if email does not exist in the database -// return false; -// } - -// // delete the role -// function delete(){ - -// $query = "DELETE FROM " . $this->table_name . " WHERE id = ?"; - -// $stmt = $this->conn->prepare($query); -// $stmt->bindParam(1, $this->id); - -// if($result = $stmt->execute()){ -// return true; -// }else{ -// return false; -// } -// } - - } ?> \ No newline at end of file diff --git a/admin/core/auth.php b/admin/core/auth.php index 4bb17fc5..c1dc58e4 100755 --- a/admin/core/auth.php +++ b/admin/core/auth.php @@ -18,8 +18,8 @@ function autoloader($class){ $database = new Database(); $db = $database->getConnection(); -$user = new User($db); -$verify = new Verify($db); +include "../inc/class_initialize.php"; + diff --git a/admin/core/authRecap.php b/admin/core/authRecap.php index 10d1b334..3953bb65 100755 --- a/admin/core/authRecap.php +++ b/admin/core/authRecap.php @@ -18,8 +18,7 @@ function autoloader($class){ $database = new Database(); $db = $database->getConnection(); -$user = new User($db); -$verify = new Verify($db); +include "../inc/class_initialize.php"; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])) { diff --git a/admin/core/clean.php b/admin/core/clean.php index a398d9d5..37ac84e4 100755 --- a/admin/core/clean.php +++ b/admin/core/clean.php @@ -16,9 +16,17 @@ include ("../class/Database.php"); $database=new Database(); $db = $database->getConnection(); + + $prx=""; + if(is_file("prefix.php")){ + require "prefix.php"; + $prx=$prefix; + } + + + $query = "DROP TABLE `".$prx."accounts`, `".$prx."color`, `".$prx."contacts`, `".$prx."default_page`, `".$prx."files`, `".$prx."menu`,`".$prx."page`, `".$prx."password_reset_temp`, `".$prx."plugins`, `".$prx."roles`, `".$prx."settings`, `".$prx."verify`, `".$prx."view_home`"; + - $query = "DROP TABLE `accounts`, `color`, `contacts`, `default_page`, `files`, `menu`,`page`, `password_reset_temp`, `plugins`, `roles`, `settings`, `verify`, `view_home`"; - $stmt = $database->conn->prepare($query); $stmt->execute(); @@ -59,6 +67,9 @@ function rmdir_recursive($dir) { unlink("../class/Database.php"); unlink("site.php"); +if(is_file("prefix.php")){ + unlink("prefix.php"); + } unlink("../inc/class_initialize.php"); diff --git a/admin/core/configdb.php b/admin/core/configdb.php index 99c58a8c..f425dd46 100755 --- a/admin/core/configdb.php +++ b/admin/core/configdb.php @@ -85,9 +85,23 @@ function autoloader($class){ $user=new User($db); +$prefix=""; +if($_POST['prefix']){ + $prefix=$_POST['prefix']."_"; +} + +$file_handle = fopen('../core/prefix.php', 'w'); +fwrite($file_handle, ''); + +chmod('../core/prefix.php',0777); + $url=explode(".",$_SERVER['SERVER_NAME']); -$webiste=""; +$website=""; $new_url=""; if($url[0]=="www"){ @@ -139,7 +153,7 @@ function autoloader($class){ ///////////////////////////////////////////////////////////// // creating user's table -$db->query("CREATE TABLE IF NOT EXISTS accounts +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."accounts ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, password VARCHAR(255) NOT NULL, @@ -148,25 +162,25 @@ function autoloader($class){ last_login datetime DEFAULT CURRENT_TIMESTAMP)"); // creating role's table -$db->query("CREATE TABLE IF NOT EXISTS roles +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."roles ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, rolename VARCHAR(255) NOT NULL)"); -$db->query("INSERT INTO roles +$db->query("INSERT INTO ".$prefix."roles (id, rolename) VALUES ('1','Admin') "); -$db->query("INSERT INTO roles +$db->query("INSERT INTO ".$prefix."roles (id, rolename) VALUES ('2','Manager') "); -$db->query("INSERT INTO roles +$db->query("INSERT INTO ".$prefix."roles (id, rolename) VALUES ('3','Editor') "); -$db->query("CREATE TABLE settings ( +$db->query("CREATE TABLE ".$prefix."settings ( id int(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, site_name VARCHAR(255) NOT NULL, site_description VARCHAR(255) NOT NULL, @@ -174,9 +188,10 @@ function autoloader($class){ footer TEXT NOT NULL, dashboard_language VARCHAR(255) NOT NULL, theme VARCHAR(255) NOT NULL, + prefix VARCHAR(255) NOT NULL, dm INT (1) DEFAULT 1)"); -$db->query("CREATE TABLE IF NOT EXISTS page +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."page ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, page_name VARCHAR(255) NOT NULL, no_mod INT (1) DEFAULT '0', @@ -188,7 +203,7 @@ function autoloader($class){ counter INT(5) DEFAULT '1') "); -$db->query("CREATE TABLE IF NOT EXISTS default_page +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."default_page ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, page_name VARCHAR(255) NOT NULL, header INT (1) DEFAULT '1', @@ -198,7 +213,7 @@ function autoloader($class){ "); -$db->query("CREATE TABLE IF NOT EXISTS menu +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."menu ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, pagename VARCHAR(255) NOT NULL, inmenu INT(1) DEFAULT '0', @@ -210,7 +225,7 @@ function autoloader($class){ chmod("../inc/func/regCheck.php",0777); -$db->query("CREATE TABLE IF NOT EXISTS plugins +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."plugins ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, plugin_name VARCHAR(255) NOT NULL, link VARCHAR(255) DEFAULT NULL, @@ -225,117 +240,117 @@ function autoloader($class){ active INT(1) NOT NULL) "); -$db->query("CREATE TABLE IF NOT EXISTS view_home +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."view_home ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, name_function VARCHAR(255) NOT NULL)"); -$db->query("INSERT INTO view_home +$db->query("INSERT INTO ".$prefix."view_home (id, name_function) VALUES ('1','color') "); -$db->query("CREATE TABLE IF NOT EXISTS files +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."files ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, filename VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL) "); -$db->query("CREATE TABLE IF NOT EXISTS color +$db->query("CREATE TABLE IF NOT EXISTS ".$prefix."color ( id INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, color VARCHAR(50) NOT NULL)"); -$db->query("INSERT INTO color +$db->query("INSERT INTO ".$prefix."color (id, color) VALUES ('1','#008db1') "); -$db->query("INSERT INTO color +$db->query("INSERT INTO ".$prefix."color (id, color) VALUES ('2','#00cc99') "); -$db->query("INSERT INTO color +$db->query("INSERT INTO ".$prefix."color (id, color) VALUES ('3','#000000') "); -$db->query("INSERT INTO color +$db->query("INSERT INTO ".$prefix."color (id, color) VALUES ('4','#ffffff') "); -$db->query("INSERT INTO accounts +$db->query("INSERT INTO ".$prefix."accounts (id, username, password,email,rolename) VALUES ('1','admin', '". $password_hash ."','". $user_email ."','Admin') "); -$db->query("INSERT INTO settings -(id, site_name, site_description,footer,dashboard_language,theme,dm) -VALUES ('1','Mini Cms', 'Create your own website','Your footer text','en','damares','1') +$db->query("INSERT INTO ".$prefix."settings +(id, site_name, site_description,footer,dashboard_language,theme,prefix,dm) +VALUES ('1','Mini Cms', 'Create your own website','Your footer text','en','damares','".$prefix."','1') "); -$db->query("INSERT INTO page +$db->query("INSERT INTO ".$prefix."page (id, page_name, no_mod, layout, header, use_name, use_desc, img, counter) VALUES ('1','index', '1', 'default', '1', '1', '1', 'visual.jpg', '1') "); -$db->query("INSERT INTO default_page +$db->query("INSERT INTO ".$prefix."default_page (id, page_name, header, use_name, use_desc, img) VALUES ('1','Login', '1', '1', '1', 'visual.jpg') "); -$db->query("INSERT INTO default_page +$db->query("INSERT INTO ".$prefix."default_page (id, page_name, header, use_name, use_desc, img) VALUES ('2','Contact', '1', '1', '1', 'visual.jpg') "); -$db->query("INSERT INTO menu +$db->query("INSERT INTO ".$prefix."menu (id, pagename, inmenu,itemorder,parent,childof) VALUES ('1','index', '1','1','1','none') "); -$db->query("INSERT INTO menu +$db->query("INSERT INTO ".$prefix."menu (id, pagename, inmenu,itemorder,parent,childof) VALUES ('2','Login', '1','2','1','none') "); -$db->query("INSERT INTO menu +$db->query("INSERT INTO ".$prefix."menu (id, pagename, inmenu,itemorder,parent,childof) VALUES ('3','Contact', '0','3','1','none') "); -$db->query("CREATE TABLE `password_reset_temp` ( +$db->query("CREATE TABLE ".$prefix."password_reset_temp ( `email` varchar(250) NOT NULL PRIMARY KEY, `token` varchar(250) NOT NULL, `expDate` datetime NOT NULL ) "); -$db->query("CREATE TABLE `verify` ( +$db->query("CREATE TABLE ".$prefix."verify ( `id` INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, `public` varchar(250) NOT NULL, `secret` varchar(250) NOT NULL, `active` INT ( 5 ) DEFAULT 0 )"); -$db->query("INSERT INTO verify +$db->query("INSERT INTO ".$prefix."verify (id, public, secret, active) VALUES ('1','PUBLIC_KEY', 'SECRET_KEY', '0') "); -$db->query("CREATE TABLE `contacts` ( +$db->query("CREATE TABLE ".$prefix."contacts ( `id` INT ( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, `label` varchar(255) NOT NULL, `email` varchar(255) NOT NULL )"); -$db->query("INSERT INTO contacts +$db->query("INSERT INTO ".$prefix."contacts (id, label, email) VALUES ('1','noreply', 'noreply@yoursite.com') "); -$db->query("INSERT INTO contacts +$db->query("INSERT INTO ".$prefix."contacts (id, label, email) VALUES ('2','Info', 'info@yoursite.com') "); diff --git a/admin/core/fetchPage.php b/admin/core/fetchPage.php index 30dc7554..9738acdb 100755 --- a/admin/core/fetchPage.php +++ b/admin/core/fetchPage.php @@ -15,16 +15,16 @@ exit; } -// loading class -include("../class/Database.php"); -include("../class/Page.php"); -include("../class/Settings.php"); +spl_autoload_register('autoloader'); + function autoloader($class){ + include("admin/class/$class.php"); + } + $database = new Database(); $db = $database->getConnection(); -$page = new Page($db); -$settings = new Settings($db); +include "../inc/class_initialize.php"; $stmt=$settings->showLangAndName(); $lang=$settings->dashboard_language; diff --git a/admin/core/mngPass.php b/admin/core/mngPass.php index edc33ddc..084b96b6 100755 --- a/admin/core/mngPass.php +++ b/admin/core/mngPass.php @@ -53,7 +53,7 @@ exit; } - $query="SELECT * FROM `password_reset_temp` WHERE `email` = '$email' LIMIT 0,1"; + $query="SELECT * FROM `".$user->prx."password_reset_temp` WHERE `email` = '$email' LIMIT 0,1"; $stmt=$db->prepare($query); $stmt->execute(); $row=$stmt->fetch(PDO::FETCH_ASSOC); @@ -61,7 +61,7 @@ $expDate=$row['expDate']; if((!$row['email']||(($row['email']) && ($expDate<$curDate)))){ - $query="DELETE FROM `password_reset_temp` WHERE `email` = '$email'"; + $query="DELETE FROM `".$user->prx."password_reset_temp` WHERE `email` = '$email'"; $stmt=$db->prepare($query); if(!$stmt->execute()){ header("Location: ../../login.php?msg=noResetDelete"); @@ -75,7 +75,7 @@ $token = $token . $addToken; $user->token=$token; // $user->addResetPassKey(); - $query="INSERT INTO `password_reset_temp` (`email`, `token`, `expDate`) + $query="INSERT INTO `".$user->prx."password_reset_temp` (`email`, `token`, `expDate`) VALUES ('".$email."', '".$token."', '".$expDate."');"; $stmt=$db->prepare($query); @@ -146,7 +146,7 @@ function get_base_url() { // update the post if($user->updatePass()){ - $query="DELETE FROM password_reset_temp WHERE email = '$email'"; + $query="DELETE FROM ".$user->prx."password_reset_temp WHERE email = '$email'"; $stmt=$db->prepare($query); if($stmt->execute()){ header("Location: ../../login.php?msg=newPass"); diff --git a/admin/core/mngPassRecap.php b/admin/core/mngPassRecap.php index 08df2c7e..0752c42b 100755 --- a/admin/core/mngPassRecap.php +++ b/admin/core/mngPassRecap.php @@ -72,7 +72,7 @@ exit; } - $query="SELECT * FROM `password_reset_temp` WHERE `email` = '$email' LIMIT 0,1"; + $query="SELECT * FROM `".$user->prx."password_reset_temp` WHERE `email` = '$email' LIMIT 0,1"; $stmt=$db->prepare($query); $stmt->execute(); $row=$stmt->fetch(PDO::FETCH_ASSOC); @@ -80,7 +80,7 @@ $expDate=$row['expDate']; if((!$row['email']||(($row['email']) && ($expDate<$curDate)))){ - $query="DELETE FROM `password_reset_temp` WHERE `email` = '$email'"; + $query="DELETE FROM `".$user->prx."password_reset_temp` WHERE `email` = '$email'"; $stmt=$db->prepare($query); if(!$stmt->execute()){ header("Location: ../../login.php?msg=noResetDelete"); @@ -94,7 +94,7 @@ $token = $token . $addToken; $user->token=$token; // $user->addResetPassKey(); - $query="INSERT INTO `password_reset_temp` (`email`, `token`, `expDate`) + $query="INSERT INTO `".$user->prx."password_reset_temp` (`email`, `token`, `expDate`) VALUES ('".$email."', '".$token."', '".$expDate."');"; $stmt=$db->prepare($query); @@ -176,7 +176,7 @@ function get_base_url() { // update the post if($user->updatePass()){ - $query="DELETE FROM password_reset_temp WHERE email = '$email'"; + $query="DELETE FROM ".$user->prx."password_reset_temp WHERE email = '$email'"; $stmt=$db->prepare($query); if($stmt->execute()){ header("Location: ../../login.php?msg=newPass"); diff --git a/admin/core/mngSettings.php b/admin/core/mngSettings.php index f240b5f8..dc345e52 100755 --- a/admin/core/mngSettings.php +++ b/admin/core/mngSettings.php @@ -323,7 +323,7 @@ }else if(filter_input(INPUT_POST,"subDestroy")){ - $query = "DROP TABLE `accounts`, `categories`, `color`, `files`, `menu`, `default_page`,`page`, `post`, `roles`, `settings`, `verify`, `contacts`,`password_reset_temp`,`view_home`,`plugins`"; + $query = "DROP TABLE `".$user->prx."accounts`, `".$user->prx."color`, `".$user->prx."files`, `".$user->prx."menu`, `".$user->prx."default_page`,`".$user->prx."page`, `".$user->prx."roles`, `".$user->prx."settings`, `".$user->prx."verify`, `".$user->prx."contacts`,`".$user->prx."password_reset_temp`,`".$user->prx."view_home`,`".$user->prx."plugins`"; $stmt = $database->conn->prepare($query); diff --git a/admin/core/prefix.php b/admin/core/prefix.php new file mode 100755 index 00000000..276cf149 --- /dev/null +++ b/admin/core/prefix.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/admin/inc/class_initialize.php b/admin/inc/class_initialize.php index 8df254f3..81eb4bef 100755 --- a/admin/inc/class_initialize.php +++ b/admin/inc/class_initialize.php @@ -1,14 +1,26 @@ prx = "dm_"; $user = new User($db); +$user->prx = "dm_"; $settings = new Settings($db); +$settings->prx = "dm_"; $role = new Role($db); +$role->prx = "dm_"; $plugins = new Plugins($db); +$plugins->prx = "dm_"; $page = new Page($db); +$page->prx = "dm_"; $menu = new Menu($db); +$menu->prx = "dm_"; $home = new Home($db); +$home->prx = "dm_"; $file = new File($db); +$file->prx = "dm_"; $database = new Database($db); +$database->prx = "dm_"; $contact = new Contact($db); +$contact->prx = "dm_"; $colors = new Colors($db); +$colors->prx = "dm_"; ?> \ No newline at end of file diff --git a/admin/inc/dbdata.php b/admin/inc/dbdata.php index 8e01216a..4c13294d 100755 --- a/admin/inc/dbdata.php +++ b/admin/inc/dbdata.php @@ -24,43 +24,42 @@