| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/prathamtour.com/application/admin/controllers/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : StaticpageController.php
* File Desc. : Staticpage controller managed all staic content pages
* Created By : Piyush Tiwari <piyush@catpl.co.in>
* Created Date : 23 May 2018
* Updated Date : 23 May 2018
* ************************************************************* */
class Admin_StaticpageController extends Zend_Controller_Action {
public $per_page_record;
protected $banner_large_image_width;
protected $banner_large_image_height;
protected $banner_medium_image_width;
protected $banner_medium_image_height;
protected $banner_small_image_width;
protected $banner_small_image_height;
public $DIR_WRITE_MODE;
public $resultset;
public $siteurl;
public $appmode;
public $dbAdapter;
public $username;
public $admin_type;
public $stylecss;
public $current_time;
public $imageUrl;
public $imageUrlHome;
public $imageUrlGallery;
public $imageUrlShow;
public $imageUrlOffer;
public function init() {
$options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('bootstrap');
$resultset = $this->resultset;
$baseUrl = $options['siteUrl'];
$this->banner_large_image_width = $options['banner_large_image_width'];
$this->banner_large_image_height = $options['banner_large_image_height'];
$this->banner_medium_image_width = $options['banner_medium_image_width'];
$this->banner_medium_image_height = $options['banner_medium_image_height'];
$this->banner_small_image_width = $options['banner_small_image_width'];
$this->banner_small_image_height = $options['banner_small_image_height'];
//echo "<pre>"; print_r($baseUrl);
//echo "<pre>"; print_r($img_h_small_gallery); die();
/* Initialize db and session access */
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->siteurl = $aConfig['bootstrap']['siteUrl'];
$this->appmode = $aConfig['bootstrap']['appmode'];
$this->per_page_record = 20;
$this->dbAdapter = Zend_Db_Table::getDefaultAdapter();
$auth = Zend_Auth::getInstance();
$authStorage = $auth->getStorage()->read();
$this->username = $authStorage->username;
$this->admin_type = $authStorage->role;
$BootStrap = $aConfig['bootstrap'];
$this->stylecss = $BootStrap['stylecss'];
$this->current_time = time();
$this->imageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/static_pages/';
$this->imageUrlHome = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/home/';
$this->imageUrlGallery = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/gallery/';
$this->imageUrlShow = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/show/';
$this->imageUrlOffer = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/offer/';
$this->DIR_WRITE_MODE = 0777;
}
public function indexAction(){
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$searchArr = array(
'Title' => $getData['Title'],
'rows' => $getData['rows'],
'page' => $getData['page'],
);
$resulsetold = $crud->getCount('tbl_static_pages', ['status' => 'Activate'], 'sid');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tbl_static_pages', ['sid', 'page_title', 'status', 'createdOn', 'updatedOn','displayOnFooter','displayOnHeader'], [''], ['sid' => 'DESC']);
$result = Zend_Json::encode($resultset);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['sid'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function homeAction() {
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$searchArr = array(
'Title' => $getData['Title'],
'rows' => $getData['rows'],
'page' => $getData['page'],
);
$resulsetold = $crud->getCount('tb_homebanner_detail', ['isMarkForDel' => 0], 'banner_id');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tb_homebanner_detail', ['*'], ['isMarkForDel' => 0], ['banner_id' => 'DESC']);
// echo"<pre>";print_r($resultset);die();
foreach ($resultset as $key => $value) {
$resultsetArr[] = [
'banner_id' => $value['banner_id'],
'image' => $value['image'],
'heading' => $value['heading'],
'isDisplayOnHome' => $value['isDisplayOnHome'],
'status' => ($value['status'] == 1) ? 'Activate': 'Dectivate',
];
}
$result = Zend_Json::encode($resultsetArr);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['banner_id'];
$finalResult["rows"] = $newResult;
echo json_encode($resultsetArr);
exit;
}
}
public function queryAction() {
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$searchArr = array(
'Title' => $getData['Title'],
'rows' => $getData['rows'],
'page' => $getData['page'],
);
$resulsetold = $crud->getCount('tbl_query', [' '], 'id');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tbl_query', ['id','office','email', 'secondEmail', 'phone', 'mobile', 'location','whatsapp_no', 'google_map'], [' '], ['id' => 'DESC']);
$result = Zend_Json::encode($resultset);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['id'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function addhomeAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Addhome();
$form->setAction("admin/staticpage/addhome");
$form->setMethod("POST");
$form->setName("add_home");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// echo"<pre>";print_r( $getData);die();
if ($form->isValid($getData)) {
if (isset($getData['save']) == "Save") {
$images = $_FILES['image']['name'];
$savePageData = [
'heading' => trim($getData['heading']),
'description' => trim($getData['description']),
'videolink' => trim($getData['videolink']),
'url' => trim($getData['url']),
'opt' => isset($getData['opt'][0]) ? $getData['opt'][0] : 0,
'status' => $getData['status'],
'isDisplayOnHome' => $getData['isDisplayOnHome'],
];
$banner_id = $crud->rv_insert('tb_homebanner_detail', $savePageData);
$fileName = '';
if (isset($images) && !empty($images)) {
$fileExt = $this->_helper->General->getFileExtension($images);
$allowedExtensions = ['jpg', 'jpeg', 'gif', 'png', 'webp'];
if(in_array($fileExt, $allowedExtensions, true)){
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrlHome . $banner_id;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $banner_id . '_' . $this->current_time . '.' . $fileExt;
$fileName1 = $banner_id . '_' . $this->current_time;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
//echo '<pre>'; print_r($orignalFolderName);die;
$temp_file_name = $_FILES["image"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
$originalLargeFolder = $orignalFolderName.'/large';
$originalMediumFolder = $orignalFolderName.'/medium';
$originalSmallFolder = $orignalFolderName.'/small';
$sourceFile = $orignalFolderName . "/" . $fileName;
$destinationFile = $orignalFolderName . "/" . $fileName1.'.webp';
$quality = 80;
if ($crud->convertToWebP($sourceFile, $destinationFile, $quality)) {
if (!file_exists($originalLargeFolder)) {
mkdir($originalLargeFolder, 0777, true);
}
if (!file_exists($originalMediumFolder)) {
mkdir($originalMediumFolder, 0777, true);
}
if (!file_exists($originalSmallFolder)) {
mkdir($originalSmallFolder, 0777, true);
}
@copy($destinationFile, $originalLargeFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalMediumFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalSmallFolder . "/" . $fileName1.'.webp');
$fileName = $fileName1.'.webp';
} else {
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
}else{
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
}
if($fileName != ''){
$editPageData = [
'image' => $fileName
];
$crud->rv_update('tb_homebanner_detail', $editPageData, ['banner_id =?' => $banner_id]);
}
$this->view->successMessage = "Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been added successfully.");
$this->_redirect("/admin/staticpage/home");
}
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function edithomeAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Edithome();
$banner_id = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/staticpage/edithome/id/" . $banner_id);
$form->setName("edit_home");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if (isset($getData['save']) == "Save") {
$banner_id = (int) @$getData['banner_id'];
$images = $_FILES['image']['name'];
if (isset($images) && !empty($images)) {
$fileExt = $this->_helper->General->getFileExtension($images);
$allowedExtensions = ['jpg', 'jpeg', 'gif', 'png', 'webp'];
if(in_array($fileExt, $allowedExtensions, true)){
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrlHome . $banner_id;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $banner_id . '_' . $this->current_time . '.' . $fileExt;
$fileName1 = $banner_id . '_' . $this->current_time;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
//echo '<pre>'; print_r($orignalFolderName);die;
$temp_file_name = $_FILES["image"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
$originalLargeFolder = $orignalFolderName.'/large';
$originalMediumFolder = $orignalFolderName.'/medium';
$originalSmallFolder = $orignalFolderName.'/small';
$sourceFile = $orignalFolderName . "/" . $fileName;
$destinationFile = $orignalFolderName . "/" . $fileName1.'.webp';
$quality = 80;
if ($crud->convertToWebP($sourceFile, $destinationFile, $quality)) {
if (!file_exists($originalLargeFolder)) {
mkdir($originalLargeFolder, 0777, true);
}
if (!file_exists($originalMediumFolder)) {
mkdir($originalMediumFolder, 0777, true);
}
if (!file_exists($originalSmallFolder)) {
mkdir($originalSmallFolder, 0777, true);
}
@copy($destinationFile, $originalLargeFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalMediumFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalSmallFolder . "/" . $fileName1.'.webp');
$fileName = $fileName1.'.webp';
} else {
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
}else{
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
}
$editPageData = [
'heading' => trim($getData['heading']),
'description' => trim($getData['description']),
'videolink' => trim($getData['videolink']),
'url' => trim($getData['url']),
'opt' => isset($getData['opt'][0]) ? $getData['opt'][0] : 0,
'status' => $getData['status'],
'isDisplayOnHome' => $getData['isDisplayOnHome'],
];
if ($fileName != "") {
$editPageData['image'] = $fileName;
}
$crud->rv_update('tb_homebanner_detail', $editPageData, ['banner_id =?' => $banner_id]);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/staticpage/home");
}
}
$result = $crud->getCmsdata('tb_homebanner_detail', ['*'], ['banner_id' => $banner_id], ['banner_id' => 'DESC']);
// echo"<pre>";print_r($result);die();
$editdata["banner_id"] = @$result->banner_id;
$editdata["heading"] = @$result->heading;
$editdata["description"] = @$result->description;
$editdata["videolink"] = @$result->videolink;
$editdata["url"] = @$result->url;
$editdata["video"] = @$result->video;
$editdata["opt"] = @$result->opt;
$editdata["status"] = @$result->status;
$editdata["isDisplayOnHome"] = @$result->isDisplayOnHome;
$editdata["image"] = @$result->image;
$form->populate($editdata);
$this->view->banner_id = @$result->banner_id;
$this->view->form = $form;
$this->view->image = @$result->image;
}
public function addqueryAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editquery();
$pId = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/staticpage/addquery/");
$form->setName("add_query");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
//echo "<pre>";print_r($getData);die;
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
//Code for check page alias name already exists or not
$page_id = (int) @$getData['id'];
$editPageData = [
'phone' => trim($getData['phone']),
// 'otherphone' => trim($getData['otherphone']),
'office' => trim($getData['office']),
'mobile' => trim($getData['mobile']),
'email' => trim($getData['email']),
'secondEmail' => trim($getData['secondEmail']),
'location' => $getData['location'],
'status' => $getData['status'],
'whatsapp_no' => $getData['whatsapp_no'],
'google_map' => trim($getData['google_map'])
];
$crud->rv_insert('tbl_query', $editPageData);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been added successfully.");
$this->_redirect("/admin/staticpage/query");
}
}
$result = $crud->getCmsdata('tbl_query', ['*'], ['id' => $pId], ['id' => 'DESC']);
$editdata["id"] = @$result->id;
$editdata["phone"] = @$result->phone;
$editdata["otherphone"] = @$result->otherphone;
$editdata["office"] = @$result->office;
$editdata["mobile"] = @$result->mobile;
$editdata["location"] = @$result->location;
$editdata["email"] = @$result->email;
$editdata["secondEmail"] = @$result->secondEmail;
$editdata["status"] = @$result->status;
$editdata["whatsapp_no"] = @$result->whatsapp_no;
$editdata["google_map"] = @$result->google_map;
$form->populate($editdata);
$this->view->form = $form;
}
public function editqueryAction() {
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editquery();
$pId = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/staticpage/editquery/id/" . $pId);
$form->setName("edit_query");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
//Code for check page alias name already exists or not
$page_id = (int) @$getData['id'];
$editPageData = [
'PayOnline' => trim($getData['PayOnline']),
'office' => trim($getData['office']),
'phone' => trim($getData['phone']),
'mobile' => trim($getData['mobile']),
'email' => trim($getData['email']),
'secondEmail' => trim($getData['secondEmail']),
'location' => $getData['location'],
'status' => $getData['status'],
'whatsapp_no' => $getData['whatsapp_no'],
'google_map' => trim($getData['google_map'])
];
$crud->rv_update('tbl_query', $editPageData, ['id =?' => $page_id]);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/staticpage/query");
}
}
$result = $crud->getCmsdata('tbl_query', ['*'], ['id' => $pId], ['id' => 'DESC']);
// echo "<pre>";print_r($result);die;
$editdata["id"] = @$result->id;
$editdata["phone"] = @$result->phone;
$editdata["PayOnline"] = @$result->PayOnline;
$editdata["office"] = @$result->office;
$editdata["mobile"] = @$result->mobile;
$editdata["location"] = @$result->location;
$editdata["email"] = @$result->email;
$editdata["secondEmail"] = @$result->secondEmail;
$editdata["status"] = @$result->status;
$editdata["whatsapp_no"] = @$result->whatsapp_no;
$editdata["google_map"] = @$result->google_map;
$form->populate($editdata);
$this->view->form = $form;
}
/**
* editpage() method is used to admin can edit cms static page
* @param password string
* @return ture
*/
public function editpageAction() {
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editstaticpage();
$pId = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/staticpage/editpage/id/" . $pId);
$form->setName("edit_static_page");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// echo "<pre>";print_r($getData);die;
//if ($form->isValid($getData)) {
if (isset($getData['save']) == "Save") {
$page_id = (int) @$getData['sid'];
if(isset($page_id) && $page_id !=''){
$page_id = (int) @$getData['sid'];
}else{
$lastRow = $crud->getCmsdata('tbl_static_pages', ['sid'], ['sid'], ['sid'=>'DESC']);
$page_id = $lastRow['sid'] +1;
}
$fileName = '';
$images = $_FILES['background_image']['name'];
if (!empty($images)) {
$fileExt = $this->_helper->General->getFileExtension($images);
$allowedExtensions = ['jpg', 'jpeg', 'gif', 'png', 'webp'];
if(in_array($fileExt, $allowedExtensions, true)){
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl.$page_id;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $page_id . '_' . $this->current_time . '.' . $fileExt;
$fileName1 = $page_id . '_' . $this->current_time;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["background_image"]["tmp_name"]; // temprary file name
move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
$originalLargeFolder = $orignalFolderName.'/large';
$originalMediumFolder = $orignalFolderName.'/medium';
$originalSmallFolder = $orignalFolderName.'/small';
$sourceFile = $orignalFolderName . "/" . $fileName;
$destinationFile = $orignalFolderName . "/" . $fileName1.'.webp';
$quality = 80;
if ($crud->convertToWebP($sourceFile, $destinationFile, $quality)) {
if (!file_exists($originalLargeFolder)) {
mkdir($originalLargeFolder, 0777, true);
}
if (!file_exists($originalMediumFolder)) {
mkdir($originalMediumFolder, 0777, true);
}
if (!file_exists($originalSmallFolder)) {
mkdir($originalSmallFolder, 0777, true);
}
@copy($destinationFile, $originalLargeFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalMediumFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalSmallFolder . "/" . $fileName1.'.webp');
$fileName = $fileName1.'.webp';
} else {
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
} else {
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
}
$editPageData = [
'page_title' => strtoupper($getData['page_title']),
'pageurl' => $getData['pageurl'],
'meta_title' => $getData['meta_title'],
'meta_keywords' => $getData['meta_keywords'],
'meta_description' => $getData['meta_description'],
'page_description' => $getData['page_description'],
'status' => $getData['status'],
'createdOn' => date("Y-m-d H:i:s"),
'updatedOn' => date("Y-m-d H:i:s"),
];
// echo "<pre>";print_r($editPageData);die;
if ($fileName !='') {
$editPageData['background_image'] = $fileName;
}
$page_id2 = (int) @$getData['sid'];
if(!empty($page_id2)){
$crud->rv_update('tbl_static_pages', $editPageData, ['sid =?' => $page_id]);
}else{
// echo "<pre>";print_r($editPageData);die;
$editPageData['identifier'] = strtolower(Catabatic_Helper::getSeoName($getData['page_title']));
$crud->rv_insert('tbl_static_pages', $editPageData);
//echo "<pre>";print_r($editPageData);die;
}
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/staticpage/index");
}
}
$result = $crud->getCmsdata('tbl_static_pages', ['*'], ['sid' => $pId], ['sid' => 'DESC']);
// echo "<pre>";print_r($result);die;
$editdata["sid"] = @$result->sid;
$editdata["page_title"] = @$result->page_title;
$editdata["pageurl"] = @$result->pageurl;
$editdata["meta_title"] = @$result->meta_title;
$editdata["meta_keywords"] = @$result->meta_keywords;
$editdata["meta_description"] = @$result->meta_description;
$editdata["background_image"] = @$result->background_image;
$editdata["page_description"] = @$result->page_description;
$editdata["status"] = @$result->status;
$form->populate($editdata);
$this->view->background_image = @$result->background_image;
$this->view->form = $form;
$this->view->sid = $result->sid;
}
public function deletepageAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
if ($tId) {
$checkdata = $crud->rv_select_row('tbl_static_pages', ['sid'], ['sid' => $tId], ['sid' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete('tbl_static_pages', ['sid =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/staticpage/index");
} else {
die('Oops some thing wrong!!.');
}
}
}
public function deletequeryAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
if ($tId) {
$checkdata = $crud->rv_select_row('tbl_query', ['id'], ['id' => $tId], ['id' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete('tbl_query', ['id =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/staticpage/query");
} else {
die('Oops some thing wrong!!.');
}
}
}
public function deletehomeAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
if ($tId) {
$checkdata = $crud->rv_select_row('tb_homebanner_detail', ['banner_id'], ['banner_id' => $tId], ['banner_id' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete('tb_homebanner_detail', ['banner_id =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/staticpage/home");
} else {
die('Oops some thing wrong!!.');
}
}
}
public function deleteimageAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout(); // disable layouts
$param = $this->getRequest()->getParams();
$id = $param['id'];
$images = $param['images'];
unlink("public/upload/home/$id/$images");
unlink("public/upload/home/$id/large/$images");
$crud = new Admin_Model_CRUD();
$crud->rv_update('tb_homebanner_detail', ['image' => NULL], ['banner_id =?' => $id]);
$response = array("status"=>true,"msg"=>"Deleted Successfully");
echo json_encode($response);
exit;
}
public function activeAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
$val = (int) $this->getRequest()->getParam("val");
if ($tId) {
try {
$updatedata = [
'isDisplayOnHome' => $val
];
$result = $crud->rv_update('tb_homebanner_detail', $updatedata, ['banner_id =?' => $tId]);
// $resultset = $crud->rv_select_all("tb_tbb2c_destinations", ['*'] ,['IsFeatured'=>1,'IsPublish'=>1,'IsMarkForDel'=>0], ['Title'=>'ASC'] );
// if(count($resultset)>6){
// $result_message = ['status' => false, 'message' => 'Limit Exceed!!'];
// echo Zend_Json::encode($result_message);
// $updatedata = [
// 'IsFeatured' => 0
// ];
// $result = $crud->rv_update('tb_tbb2c_destinations', $updatedata, ['DesSysId =?' => $tId]);
// exit;
// }
if (!$result) {
$result_message = ['status' => false, 'message' => 'Oops something wrong!!'];
echo Zend_Json::encode($result_message);
exit;
} else {
$result_message = ['status' => true, 'message' => 'Active successfully'];
echo Zend_Json::encode($result_message);
exit;
}
} catch (Exception $ex) {
$ex->getMessage();
}
}
}
public function footerAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
$val = (int) $this->getRequest()->getParam("val");
$header = (int) $this->getRequest()->getParam("header");
if($header==1){
if ($tId) {
try {
$editPageData = [
'displayOnHeader' => $val
];
//$result = $crud->rv_update('tbl_static_pages', $updatedata, ['sid =?' => $tId]);
$result = $crud->rv_update('tbl_static_pages', ['displayOnHeader' => $val], ['sid =?' => $tId]);
if (!$result) {
$result_message = ['status' => false, 'message' => 'Oops something wrong!!'];
echo Zend_Json::encode($result_message);
exit;
} else {
$result_message = ['status' => true, 'message' => 'Active successfully'];
echo Zend_Json::encode($result_message);
exit;
}
} catch (Exception $ex) {
$ex->getMessage();
}
}
}else{ if($tId) {
try {
$editPageData = [
'displayOnFooter' => $val
];
//$result = $crud->rv_update('tbl_static_pages', $updatedata, ['sid =?' => $tId]);
$result = $crud->rv_update('tbl_static_pages', ['displayOnFooter' => $val], ['sid =?' => $tId]);
if (!$result) {
$result_message = ['status' => false, 'message' => 'Oops something wrong!!'];
echo Zend_Json::encode($result_message);
exit;
} else {
$result_message = ['status' => true, 'message' => 'Active successfully'];
echo Zend_Json::encode($result_message);
exit;
}
} catch (Exception $ex) {
$ex->getMessage();
}
}}
}
public function sanitize_data($string) {
$searchArr = array("iframe", "script", "document", "write", "alert", "%", "@", "$", ";", "+", "|", "#", "<", ">", ")", "(", "'", "\'", ",", "and ", " &", "& ", "and", " and", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$input_data = strtolower($string);
$input_data = str_replace($searchArr, "", $input_data);
$input_data = str_replace(" ", "-", $input_data);
//echo $input_data; die;
return $input_data;
}
/**
* checklogin() method is used to check admin logedin or not
* @param Null
* @return Array
*/
public function checklogin() {
if (($this->admin_type == "superadmin") || ($this->admin_type == "admin")) {
$auth = Zend_Auth::getInstance();
$hasIdentity = $auth->hasIdentity();
/* * ************* check admin identity *********** */
if (!$hasIdentity) {
$this->_redirect('admin/index');
}
} else {
$this->_redirect('admin/index');
}
}
public function offerAction(){
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// explode();
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
$images = $_FILES['image']['name'];
if (!empty($images)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrlOffer;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $this->current_time . '.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["image"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
if ($fileName != "") {
$image_edit = $fileName;
}
$editPageData = [
'title' => trim($getData['title']),
'shortDescription' => $getData['shortDescription'],
'description' => trim($getData['description']),
'status' => $getData['status'],
];
if ($fileName) {
$editPageData['image'] = $image_edit;
}
$crud->rv_update('tbl_offers', $editPageData, ['id =?' => 1]);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/staticpage/offer");
}
}
$result = $crud->getCmsdata('tbl_offers', ['*'], ['id' => 1], ['id' => 'DESC']);
$this->view->editData = $result;
}
public function highlightAction() {
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$searchArr = array(
'Title' => $getData['Title'],
'rows' => $getData['rows'],
'page' => $getData['page'],
);
$resulsetold = $crud->getCount('tb_highlight_details', ['isMarkForDel' => 0], 'highlight_id');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tb_highlight_details', ['highlight_id', 'heading','title', 'description', 'isDisplayOnHome','status'], ['isMarkForDel' => 0], ['highlight_id' => 'DESC']);
// echo"<pre>";print_r($resultset);die();
foreach ($resultset as $key => $value) {
$resultsetArr[] = [
'highlight_id' => $value['highlight_id'],
'heading' => $value['heading'],
'title' => $value['title'],
'description' => $value['description'],
'isDisplayOnHome' => $value['isDisplayOnHome'],
'status' => ($value['status'] == 1) ? 'Activate': 'Dectivate',
];
}
$result = Zend_Json::encode($resultsetArr);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['highlight_id'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function addhighlightAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Addhighlight();
$form->setAction("admin/staticpage/addhighlight");
$form->setMethod("POST");
$form->setName("add_highlight");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if ($form->isValid($getData)) {
if (isset($getData['save']) == "Save") {
$savePageData = [
'heading' => trim($getData['heading']),
'title' => trim($getData['title']),
'description' => trim($getData['description']),
'url' => trim($getData['url']),
'opt' => isset($getData['opt'][0]) ? $getData['opt'][0] : 0,
'status' => $getData['status'],
'isDisplayOnHome' => $getData['isDisplayOnHome'],
];
$highlight_id = $crud->rv_insert('tb_highlight_details', $savePageData);
$this->view->successMessage = "Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been added successfully.");
$this->_redirect("/admin/staticpage/highlight");
}
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function edithighlightAction(){
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Edithighlight();
$highlight_id = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/staticpage/edithighlight/id/" . $highlight_id);
$form->setName("edit_highlight");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// echo"<pre>";print_r($getData);die;
// explode();
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
//Code for check page alias name already exists or not
$highlight_id = (int) @$getData['highlight_id'];
//echo"<pre>";print_r($getData);die();
$editPageData = [
'heading' => trim($getData['heading']),
'title' => trim($getData['title']),
'description' => trim($getData['description']),
'url' => trim($getData['url']),
'opt' => isset($getData['opt'][0]) ? $getData['opt'][0] : 0,
'status' => $getData['status'],
'isDisplayOnHome' => $getData['isDisplayOnHome'],
];
$crud->rv_update('tb_highlight_details', $editPageData, ['highlight_id =?' => $highlight_id]);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/staticpage/highlight");
}
}
$result = $crud->getCmsdata('tb_highlight_details', ['*'], ['highlight_id' => $highlight_id], ['highlight_id' => 'DESC']);
// echo"<pre>";print_r($result);die();
$editdata["highlight_id"] = @$result->highlight_id;
$editdata["heading"] = @$result->heading;
$editdata["title"] = @$result->title;
$editdata["description"] = @$result->description;
$editdata["url"] = @$result->url;
$editdata["opt"] = @$result->opt;
$editdata["status"] = @$result->status;
$editdata["isDisplayOnHome"] = @$result->isDisplayOnHome;
$form->populate($editdata);
$this->view->highlight_id = @$result->highlight_id;
$this->view->form = $form;
}
public function deletehighlightAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
if ($tId) {
$checkdata = $crud->rv_select_row('tb_highlight_details', ['highlight_id'], ['highlight_id' => $tId], ['highlight_id' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete('tb_highlight_details', ['highlight_id =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/staticpage/highlight");
} else {
die('Oops some thing wrong!!.');
}
}
}
public function topbannerAction() {
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$searchArr = array(
'Title' => $getData['Title'],
'rows' => $getData['rows'],
'page' => $getData['page'],
);
$resulsetold = $crud->getCount('tb_homebanner_detail', ['isMarkForDel' => 0], 'banner_id');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tb_homebanner_detail', ['banner_id', 'image', 'heading', 'isDisplayOnBanner', 'description', 'isDisplayOnHome','status'], ['isMarkForDel' => 0, 'isDisplayOnBanner' => 1], ['banner_id' => 'DESC']);
// echo"<pre>";print_r($resultset);die();
foreach ($resultset as $key => $value) {
$resultsetArr[] = [
'banner_id' => $value['banner_id'],
'image' => $value['image'],
'heading' => $value['heading'],
'isDisplayOnHome' => $value['isDisplayOnHome'],
'status' => ($value['status'] == 1) ? 'Activate': 'Dectivate',
];
}
$result = Zend_Json::encode($resultsetArr);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['banner_id'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function edittopbannerAction(){
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Edithome();
$banner_id = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/staticpage/edithome/id/" . $banner_id);
$form->setName("edit_home");
// echo"<pre>";print_r($this->imageUrlHome );die();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// echo"<pre>";print_r($_FILES);die;
// explode();
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
//Code for check page alias name already exists or not
$banner_id = (int) @$getData['banner_id'];
$images = $_FILES['image']['name'];
if (isset($images) && !empty($images)) {
$fileExt = $this->_helper->General->getFileExtension($images);
$allowedExtensions = ['jpg', 'jpeg', 'gif', 'png', 'webp'];
if(in_array($fileExt, $allowedExtensions, true)){
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrlHome . $banner_id;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $banner_id . '_' . $this->current_time . '.' . $fileExt;
$fileName1 = $banner_id . '_' . $this->current_time;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
//echo '<pre>'; print_r($orignalFolderName);die;
$temp_file_name = $_FILES["image"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
$originalLargeFolder = $orignalFolderName.'/large';
$originalMediumFolder = $orignalFolderName.'/medium';
$originalSmallFolder = $orignalFolderName.'/small';
$sourceFile = $orignalFolderName . "/" . $fileName;
$destinationFile = $orignalFolderName . "/" . $fileName1.'.webp';
$quality = 80;
if ($crud->convertToWebP($sourceFile, $destinationFile, $quality)) {
if (!file_exists($originalLargeFolder)) {
mkdir($originalLargeFolder, 0777, true);
}
if (!file_exists($originalMediumFolder)) {
mkdir($originalMediumFolder, 0777, true);
}
if (!file_exists($originalSmallFolder)) {
mkdir($originalSmallFolder, 0777, true);
}
@copy($destinationFile, $originalLargeFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalMediumFolder . "/" . $fileName1.'.webp');
@copy($destinationFile, $originalSmallFolder . "/" . $fileName1.'.webp');
$fileName = $fileName1.'.webp';
} else {
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
}else{
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
}
$editPageData = [
'heading' => trim($getData['heading']),
'description' => trim($getData['description']),
'videolink' => trim($getData['videolink']),
'url' => trim($getData['url']),
'opt' => isset($getData['opt'][0]) ? $getData['opt'][0] : 0,
'status' => $getData['status'],
'isDisplayOnHome' => $getData['isDisplayOnHome'],
];
if ($fileName != "") {
$editPageData['image'] = $fileName;
}
$crud->rv_update('tb_homebanner_detail', $editPageData, ['banner_id =?' => $banner_id]);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/staticpage/home");
}
}
$result = $crud->getCmsdata('tb_homebanner_detail', ['*'], ['banner_id' => $banner_id], ['banner_id' => 'DESC']);
// echo"<pre>";print_r($result);die();
$editdata["banner_id"] = @$result->banner_id;
$editdata["heading"] = @$result->heading;
$editdata["description"] = @$result->description;
$editdata["videolink"] = @$result->videolink;
$editdata["url"] = @$result->url;
$editdata["video"] = @$result->video;
$editdata["opt"] = @$result->opt;
$editdata["status"] = @$result->status;
$editdata["isDisplayOnHome"] = @$result->isDisplayOnHome;
$editdata["image"] = @$result->image;
$form->populate($editdata);
$this->view->banner_id = @$result->banner_id;
$this->view->form = $form;
$this->view->image = @$result->image;
}
}