Created
August 23, 2020 14:39
-
-
Save jack60612/c4b9d0d3b89bf7c2d84975a09181d014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controllers; | |
$db = db_connect(); | |
use DB; | |
class AdminController extends BaseController | |
{ | |
function Index(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"]= $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/index",$data); | |
}else{ | |
foreach($_FILES as $key=>$items){ | |
if($_FILES[$key]["name"]){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
$path = "uploads/images/".$_FILES[$key]["name"]; | |
if($data){ | |
move_uploaded_file($_FILES[$key]["tmp_name"],$path); | |
$this->db->where("id",$data->id)->set(["content"=>$path])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$path,"page_id"=>1])->insert("page_content"); | |
} | |
} | |
} | |
foreach($_POST as $key=>$items){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
/* | |
if($_FILES[$key]["name"]!=""){ | |
} | |
*/ | |
if($data){ | |
$this->db->where("id",$data->id)->set(["content"=>$items])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$items,"page_id"=>1])->insert("page_content"); | |
} | |
} | |
$temp["content"]= $this->db->get("page_content")->result_array(); | |
$temp["saved"] = true; | |
$this->load->view("admin/index",$temp); | |
} | |
} | |
//____________Page 1_____________________ | |
function Home(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["partners"] = $this->db->get("partners")->result_array(); | |
$data["content"]= $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/home",$data); | |
}else{ | |
foreach($_FILES as $key=>$items){ | |
if($_FILES[$key]["name"]){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
$path = "uploads/images/".$_FILES[$key]["name"]; | |
if($data){ | |
move_uploaded_file($_FILES[$key]["tmp_name"],$path); | |
$this->db->where("id",$data->id)->set(["content"=>$path])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$path,"page_id"=>1])->insert("page_content"); | |
} | |
} | |
} | |
foreach($_POST as $key=>$items){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
/* | |
if($_FILES[$key]["name"]!=""){ | |
} | |
*/ | |
if($data){ | |
$this->db->where("id",$data->id)->set(["content"=>$items])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$items,"page_id"=>1])->insert("page_content"); | |
} | |
} | |
$message["saved"] = "true"; | |
$message["partners"] = $this->db->get("partners")->result_array(); | |
$message["content"]= $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/home",$message); | |
} | |
} | |
function Partners(){ | |
$image = $_FILES["home-partner-logo-add"]; | |
$image_alt = $this->input->post("home-partner-addlogo-alt"); | |
$path = "uploads/partners/".$image["name"]; | |
move_uploaded_file($image["tmp_name"],$path); | |
$this->db->set(["image"=>$path,"image_alt"=>$image_alt])->insert("partners"); | |
redirect(base_url()."Admin/Home"); | |
} | |
function PartnersDelete(){ | |
$id = $this->input->post("partner-delete-id"); | |
$this->db->where("id",$id)->delete("partners"); | |
redirect(base_url()."Admin/Home"); | |
} | |
function PartnersEdit(){ | |
$id = $this->input->post("partner-edit-id"); | |
$image_alt = $this->input->post("home-partner-logo-alt"); | |
if($_FILES["home-partner-logo-update"]["name"]!=""){ | |
$image = $_FILES["home-partner-logo-update"]; | |
$path = "uploads/partners/".$image["name"]; | |
move_uploaded_file($image["tmp_name"],$path); | |
$this->db->where("id",$id)->set(["image"=>$path,"image_alt"=>$image_alt])->update("partners"); | |
}else{ | |
$this->db->where("id",$id)->set(["image_alt"=>$image_alt])->update("partners"); | |
} | |
redirect(base_url()."Admin/Home"); | |
} | |
function getPartner(){ | |
$id = $this->input->post("id"); | |
$data = $this->db->where("id",$id)->get("partners")->row(); | |
echo json_encode($data); | |
} | |
//____________Page 2_____________________ | |
function About(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$data["testimonails"] = $this->db->get("testimonails")->result_array(); | |
$this->load->view("admin/about",$data); | |
}else{ | |
foreach($_FILES as $key=>$items){ | |
if($_FILES[$key]["name"]){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
$path = "uploads/images/".$_FILES[$key]["name"]; | |
if($data){ | |
move_uploaded_file($_FILES[$key]["tmp_name"],$path); | |
$this->db->where("id",$data->id)->set(["content"=>$path])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$path,"page_id"=>2])->insert("page_content"); | |
} | |
} | |
} | |
/* echo "<pre>"; | |
print_r($_POST); | |
die(); | |
*/ | |
foreach($_POST as $key=>$items){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
/* | |
if($_FILES[$key]["name"]!=""){ | |
} | |
*/ | |
if($data){ | |
$this->db->where("id",$data->id)->set(["content"=>$items])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$items,"page_id"=>2])->insert("page_content"); | |
} | |
} | |
$message["saved"] = "true"; | |
$message["content"]= $this->db->get("page_content")->result_array(); | |
$message["testimonails"] = $this->db->get("testimonails")->result_array(); | |
$this->load->view("admin/about",$message); | |
} | |
} | |
function Testimonial(){ | |
$about_mini_title = $this->input->post("about-testimonial-mini-title"); | |
$about_large_title = $this->input->post("about-testimonial-large-title"); | |
// print_r($_POST);die(); | |
//Large Heading | |
$check = $this->db->where("content_key","about-testimonial-large-title")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("id",$check->id)->set(["content"=>$about_large_title])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"about-testimonial-large-title","content"=>$about_large_title,"page_id"=>2])->insert("page_content"); | |
} | |
//Mini Heading | |
$check = $this->db->where("content_key","about-testimonial-mini-title")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("id",$check->id)->set(["content"=>$about_mini_title])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"about-testimonial-mini-title","content"=>$about_mini_title,"page_id"=>2])->insert("page_content"); | |
} | |
redirect(base_url()."Admin/About"); | |
} | |
function Testimonial_Add_Item(){ | |
$alt_array = $this->input->post("testi-alt-insert"); | |
$testimonail_author_name = $this->input->post("testi-author-insert"); | |
$testimonail_author_designation = $this->input->post("testi-designation-insert"); | |
$testimonail_author_desc = $this->input->post("testi-decription-insert"); | |
$path = "uploads/testimonails/"; | |
$items = $_FILES["testi-file-insert"]; | |
move_uploaded_file($items["tmp_name"],$path.$items["name"]); | |
$this->db->insert("testimonails", | |
[ | |
"image_path"=>$path.$items["name"], | |
"image_alt"=>$alt_array, | |
"author_name"=>$testimonail_author_name, | |
"author_designation"=>$testimonail_author_designation, | |
"authoir_description"=>$testimonail_author_desc, | |
] | |
); | |
redirect(base_url()."Admin/About"); | |
} | |
function Testimonial_Edit_Item(){ | |
/* print_r($_POST); | |
die(); */ | |
$alt_array = $this->input->post("testi-alt-update"); | |
$testimonail_author_name = $this->input->post("testi-author-update"); | |
$testimonail_author_designation = $this->input->post("testi-designation-update"); | |
$testimonail_author_desc = $this->input->post("testi-decription-update"); | |
$id = $this->input->post("testi-data-insert-id"); | |
$path = "uploads/testimonails/"; | |
$items = $_FILES["testi-file-update"]; | |
move_uploaded_file($items["tmp_name"],$path.$items["name"]); | |
if($items["name"] != ""){ | |
$this->db->where("id",$id)->set([ | |
"image_path"=>$path.$items["name"], | |
"image_alt"=>$alt_array, | |
"author_name"=>$testimonail_author_name, | |
"author_designation"=>$testimonail_author_designation, | |
"authoir_description"=>$testimonail_author_desc, | |
])->update("testimonails"); | |
}else{ | |
$this->db->where("id",$id)->set([ | |
"image_alt"=>$alt_array, | |
"author_name"=>$testimonail_author_name, | |
"author_designation"=>$testimonail_author_designation, | |
"authoir_description"=>$testimonail_author_desc, | |
])->update("testimonails" | |
); | |
} | |
redirect(base_url()."Admin/About"); | |
} | |
function Testimonial_Delete_Item(){ | |
$id = $this->input->post("testi-delete-id"); | |
$this->db->where("id",$id)->delete("testimonails"); | |
redirect(base_url()."Admin/About"); | |
} | |
function Testimonial_Get_Item(){ | |
$id = $this->input->post("id"); | |
$data = $this->db->where("id",$id)->get("testimonails")->row(); | |
echo json_encode($data); | |
} | |
//_____________________Page 3 Shop_____________________________ | |
function Shop(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/shop",$data); | |
}else{ | |
foreach($_FILES as $key=>$items){ | |
if($_FILES[$key]["name"]){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
$path = "uploads/images/".$_FILES[$key]["name"]; | |
if($data){ | |
move_uploaded_file($_FILES[$key]["tmp_name"],$path); | |
$this->db->where("id",$data->id)->set(["content"=>$path])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$path,"page_id"=>3])->insert("page_content"); | |
} | |
} | |
} | |
foreach($_POST as $key=>$items){ | |
$data = $this->db->where("content_key",$key)->get("page_content")->row(); | |
/* | |
if($_FILES[$key]["name"]!=""){ | |
} | |
*/ | |
if($data){ | |
$this->db->where("id",$data->id)->set(["content"=>$items])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>$key,"content"=>$items,"page_id"=>3])->insert("page_content"); | |
} | |
} | |
$message["saved"] = "true"; | |
$message["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/shop",$message); | |
} | |
} | |
//_____________________Page 4 Documentation_____________________________ | |
function Documentation(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["doc"] = $this->db->get("documentation")->result_array(); | |
$this->load->view("admin/documentation",$data); | |
}else{ | |
$tab_title = $this->input->post("tab-title"); | |
$tab_desc = $this->input->post("tab-desc"); | |
$this->db->truncate("documentation"); | |
for($i=0;$i<count($tab_title);$i++){ | |
$data = [ | |
"title"=>$tab_title[$i], | |
"content"=>$tab_desc[$i], | |
]; | |
$this->db->insert("documentation",$data); | |
} | |
$message["saved"] = "true"; | |
$message["doc"] = $this->db->get("documentation")->result_array(); | |
$this->load->view("admin/documentation",$message); | |
} | |
} | |
//_____________________Page 5 Help_____________________________ | |
function Help(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["help"] = $this->db->get("help")->result_array(); | |
$this->load->view("admin/help",$data); | |
}else{ | |
$help_question = $this->input->post("help_question"); | |
$help_question_answer = $this->input->post("help_question_answer"); | |
$this->db->truncate("help"); | |
for($i=0;$i<count($help_question);$i++){ | |
$data = [ | |
"title"=>$help_question[$i], | |
"content"=>$help_question_answer[$i], | |
]; | |
$this->db->insert("help",$data); | |
} | |
$message["saved"] = "true"; | |
$message["help"] = $this->db->get("help")->result_array(); | |
$this->load->view("admin/help",$message); | |
} | |
} | |
//_______________________Page 7 Privacy_Policy________________________________ | |
function Privacy_Policy(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/privacy-policy",$data); | |
}else{ | |
$pp_heading = $this->input->post("pp_heading"); | |
$Privacy_Policy = $this->input->post("privacy_text"); | |
$check = $this->db->where("content_key","pp_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","pp_heading")->set(["content_key"=>"pp_heading","content"=>$pp_heading,"page_id"=>5])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"pp_heading","content"=>$pp_heading,"page_id"=>5])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","privacy_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","privacy_text")->set(["content_key"=>"privacy_text","content"=>$Privacy_Policy,"page_id"=>5])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"privacy_text","content"=>$Privacy_Policy,"page_id"=>5])->insert("page_content"); | |
} | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/privacy-policy",$data); | |
} | |
} | |
//_______________________Page 8 Term_And_Condition________________________________ | |
function Term_And_Condition(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/terms-and-conditions",$data); | |
}else{ | |
$tc_heading = $this->input->post("tc_heading"); | |
$Privacy_Policy = $this->input->post("tc_text"); | |
$check = $this->db->where("content_key","tc_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","tc_heading")->set(["content_key"=>"tc_heading","content"=>$tc_heading])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"tc_heading","content"=>$tc_heading,"page_id"=>6])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","tc_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","tc_text")->set(["content_key"=>"tc_text","content"=>$Privacy_Policy])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"tc_text","content"=>$Privacy_Policy,"page_id"=>6])->insert("page_content"); | |
} | |
$data["saved"] = "true"; | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/terms-and-conditions",$data); | |
} | |
} | |
//_______________________Page 9 cps________________________________ | |
function cps(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/cps",$data); | |
}else{ | |
$cps_heading = $this->input->post("cps_heading"); | |
$cps = $this->input->post("cps_text"); | |
$check = $this->db->where("content_key","cps_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","cps_heading")->set(["content_key"=>"cps_heading","content"=>$cps_heading,"page_id"=>5])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"cps_heading","content"=>$cps_heading,"page_id"=>5])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","cps_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","cps_text")->set(["content_key"=>"cps_text","content"=>$cps,"page_id"=>5])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"cps_text","content"=>$cps,"page_id"=>5])->insert("page_content"); | |
} | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/cps",$data); | |
} | |
} | |
//_______________________Page 10 Non-discrimination________________________________ | |
function nondiscrimination(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/nondiscrimination",$data); | |
}else{ | |
$nd_heading = $this->input->post("nd_heading"); | |
$nondiscrimination = $this->input->post("nondiscrim_text"); | |
$check = $this->db->where("content_key","nd_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","nd_heading")->set(["content_key"=>"nd_heading","content"=>$nd_heading,"page_id"=>5])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"nd_heading","content"=>$nd_heading,"page_id"=>5])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","nondiscrim_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","nondiscrim_text")->set(["content_key"=>"nondiscrim_text","content"=>$nondiscrimination,"page_id"=>5])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"nondiscrim_text","content"=>$nondiscrimination,"page_id"=>5])->insert("page_content"); | |
} | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/nondiscrimination",$data); | |
} | |
} | |
//_______________________Page 10 cp________________________________ | |
function cp(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/cp",$data); | |
}else{ | |
$cp_heading = $this->input->post("cp_heading"); | |
$cp = $this->input->post("cp_text"); | |
$check = $this->db->where("content_key","cp_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","cp_heading")->set(["content_key"=>"cp_heading","content"=>$cp_heading,"page_id"=>11])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"cp_heading","content"=>$cp_heading,"page_id"=>11])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","cp_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","cp_text")->set(["content_key"=>"cp_text","content"=>$cp,"page_id"=>11])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"cp_text","content"=>$cp,"page_id"=>11])->insert("page_content"); | |
} | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/cp",$data); | |
} | |
} | |
//_______________________Page 11 legal________________________________ | |
function legal(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/legal",$data); | |
}else{ | |
$legal_heading = $this->input->post("legal_heading"); | |
$legal = $this->input->post("legal_text"); | |
$check = $this->db->where("content_key","legal_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","legal_heading")->set(["content_key"=>"legal_heading","content"=>$legal_heading,"page_id"=>10])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"legal_heading","content"=>$legal_heading,"page_id"=>10])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","legal_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","legal_text")->set(["content_key"=>"legal_text","content"=>$legal,"page_id"=>10])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"legal_text","content"=>$legal,"page_id"=>5])->insert("page_content"); | |
} | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/legal",$data); | |
} | |
} | |
//_______________________Page 13 codeofconduct________________________________ | |
function codeofconduct(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/codeofconduct",$data); | |
}else{ | |
$coc_heading = $this->input->post("coc_heading"); | |
$codeofconduct = $this->input->post("coc_text"); | |
$check = $this->db->where("content_key","coc_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","coc_heading")->set(["content_key"=>"coc_heading","content"=>$coc_heading])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"coc_heading","content"=>$coc_heading,"page_id"=>13])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","coc_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","coc_text")->set(["content_key"=>"tc_text","content"=>$codeofconduct])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"coc_text","content"=>$codeofconduct,"page_id"=>13])->insert("page_content"); | |
} | |
$data["saved"] = "true"; | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/codeofconduct",$data); | |
} | |
} | |
//_______________________Page 12 trademark policy________________________________ | |
function tp(){ | |
if($_SERVER["REQUEST_METHOD"] == "GET"){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/tp",$data); | |
}else{ | |
$tp_heading = $this->input->post("tp_heading"); | |
$tp = $this->input->post("tp_text"); | |
$check = $this->db->where("content_key","tp_heading")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","tp_heading")->set(["content_key"=>"tp_heading","content"=>$tp_heading])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"tp_heading","content"=>$tp_heading,"page_id"=>12])->insert("page_content"); | |
} | |
$check = $this->db->where("content_key","tp_text")->get("page_content")->row(); | |
if($check){ | |
$this->db->where("content_key","tp_text")->set(["content_key"=>"tp_text","content"=>$tp])->update("page_content"); | |
}else{ | |
$this->db->set(["content_key"=>"tp_text","content"=>$tp,"page_id"=>12])->insert("page_content"); | |
} | |
$data["saved"] = "true"; | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/tp",$data); | |
} | |
} | |
function profile(){ | |
$data["content"] = $this->db->get("page_content")->result_array(); | |
$this->load->view("admin/profile",$data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment