| 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 : ContactusController.php
* File Desc. : Contactus controller managed all contact queries
* Created By : Piyush Tiwari <piyush@catpl.co.in>
* Created Date : 23 May 2018
* Updated Date : 23 May 2018
* ************************************************************* */
class Admin_FaqController extends Zend_Controller_Action {
public $dbAdapter;
public $perPageLimit;
public $siteurl;
public $DIR_WRITE_MODE;
protected $tablenameRegion;
public function init() {
/* Initialize db and session access */
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->siteurl = $aConfig['bootstrap']['siteUrl'];
$this->appmode = $aConfig['bootstrap']['appmode'];
$this->per_page_record = 25;
$this->dbAdapter = Zend_Db_Table::getDefaultAdapter();
$auth = Zend_Auth::getInstance();
$authStorage = $auth->getStorage()->read();
$this->tablename ='tb_tbb2c_packages_master';
$this->username = $authStorage->username;
$this->admin_type = $authStorage->role;
$options = $aConfig['bootstrap'];
$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'];
$this->large_image_width = $options['large_image_width'];
$this->large_image_height = $options['large_image_height'];
$this->medium_image_width = $options['medium_image_width'];
$this->medium_image_height = $options['medium_image_height'];
$this->small_image_width = $options['small_image_width'];
$this->small_image_height = $options['small_image_height'];
$this->current_time = time();
$this->imageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/static_pages/';
$this->iconUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/promotion/essential/';
$this->imageUrlHome = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/promotion/banner/';
$this->imageUrlGallery = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/gallery/';
$this->imageUrlOffer = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/offer/';
$this->imageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/destinations/';
$this->regionImageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/region/';
$this->countryImageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/country/';
$this->stateImageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/state/';
$this->DIR_WRITE_MODE = 0777;
}
/**
* index() method is used to admin login for form call
* @param Null
* @return Array
*/
public function activedAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
$val = (int) $this->getRequest()->getParam("val");
if ($tId) {
try {
$updatedata = [
'DisplaySaudiHome' => $val
];
$result = $crud->rv_update('tb_tbb2c_destinations', $updatedata, ['DesSysId =?' => $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 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('tb_tbb2c_faq', ['isMarkForDel' => 0], 'DesSysId');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tb_tbb2c_faq', ['DesSysId', 'content_heading', 'content_description','isDisplayOnHome'], ['isMarkForDel' => 0,'isPublish' =>1], ['DesSysId' => 'DESC']);
// print_r( $resultset);die;'IsPublish' => 1,
foreach ($resultset as $key => $value) {
$resultsetArr[] = [
'DesSysId' => $value['DesSysId'],
'content_heading' => $value['content_heading'],
'content_description' => $value['content_description'],
'isDisplayOnHome' => $value['isDisplayOnHome'],
'isMarkForDel' =>0,
'isPublish' =>1,
];
}
$result = Zend_Json::encode($resultsetArr);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['DesSysId'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function editfaqAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
// $form = new Admin_Form_Editdestinationpage();
$pId = $this->getRequest()->getParam("id");
$page = ($this->getRequest()->getParam("page")) ? $this->getRequest()->getParam("page") : 1;
//$form->setMethod("POST");
//$form->setAction("admin/destination/editdesti/id/" . $pId . "/page/$page");
// $form->setName("edit_destination_page");
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") {
// echo "<pre>";print_r($getData);die;
/* * ****************** Starts : destinations Image upload here **************** */
/* * ****************** End : destinations Image upload here **************** */
/* * ****************** Starts : destinations Image upload here
/* * ****************** End : destinations Image upload here **************** */
$id = $getData['DesSysId'];
$editDestinationData = [
'content_heading' => ($getData['content_heading']),
'content_description' => ($getData['content_description']),
];
$crud->rv_update('tb_tbb2c_faq', $editDestinationData, ['DesSysId =?' => $id]);
$this->view->successMessage = "Promotion Content has been Updated successfully.";
$this->_helper->flashMessenger->addMessage("Destination has been updated successfully.");
$this->_redirect("/admin/faq/index");
}
$result = $crud->rv_select_static('tb_tbb2c_faq', ['DesSysId', 'content_heading', 'content_description'], ['isMarkForDel' => 0,'isPublish' =>1,'DesSysId' => $pId ], ['DesSysId' => 'DESC']);
// $result = $crud->getCmsdata('tb_tbb2c_destinations', ['*'], ['DesSysId' => $pId], ['DesSysId' => 'DESC']);
//$result = $crud->getDestinations( ['tbl.IsMarkForDel'=>0 ,'DesSysId' => $pId ], ['tbl.DesSysId'=>'DESC'] );
$result = $result[0];
//echo "<pre>";print_r($result);die;
//$this->view->pId = $pId;
//$editdata["id"] = $result['DesSysId'];
//$editdata["title"] = $result['Title'];
//$this->view->image = $result['Image'];
//$this->view->banner_image = $result['Bannerimg'];
//$form->($editdata);
// $this->view->banner_id = @$result->banner_id;
//$this->view->editpromotioncontent = $result;
// $this->view->image = @$result->image; //$this->view->page = $page;
$this->view->getdata = $result;
}
public function addfaqAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
//$form = new Admin_Form_Adddestination();
$tId = (int) $this->getRequest()->getParam("id");
//$form->setAction("admin/promotion/addpromotioncontent");
//$form->setMethod("POST");
//$form->setName("add_destination");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
//echo "<pre>";print_r($getData);die;
if (isset($getData['save']) == "Save") {
// $image = $_FILES['image']['name'];
// $target_dir = "public/upload/destinations/";
// $target_file = $target_dir . basename($_FILES["image"]["name"]);
// $target_file1 = $target_dir . basename($_FILES["banner_image"]["name"]);
// $uploadOk = 1;
// if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
// "The file " . basename($_FILES["image"]["name"]) . " has been uploaded.";
// }
// if (move_uploaded_file($_FILES["banner_image"]["tmp_name"], $target_file1)) {
// "The file " . basename($_FILES["banner_image"]["name"]) . " has been uploaded.";
// }
// $image = $_FILES["image"]["name"];
// $bannerimage = $_FILES['banner_image']['name'];
$savePageData = [
'content_heading' => ($getData['content_heading']),
'content_description' => ($getData['content_description']),
'IsPublish' => 1,
'IsMarkForDel' => 0,
];
// echo "<pre>";print_r($savePageData);die;
$crud->rv_insert('tb_tbb2c_faq', $savePageData);
$this->view->successMessage = "Destination has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Destination has been added successfully.");
$this->_redirect("/admin/faq/index");
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function displayHeaderAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
$val = (int) $this->getRequest()->getParam("val");
if ($tId) {
try {
$updatedata = [
'DisplayOnHeader' => $val
];
$result = $crud->rv_update('tb_promotion_homebanner_detail', $updatedata, ['DesSysId =?' => $tId]);
if (!$result) {
$result_message = ['status' => false, 'message' => 'Oops33 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 deletefaqAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
//echo $tId;die;
if ($tId) {
$checkdata = $crud->rv_select_row('tb_tbb2c_faq', ['DesSysId'], ['DesSysId' => $tId], ['DesSysId' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete('tb_tbb2c_faq', ['DesSysId =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Deleted successfully.");
$this->_redirect("/admin/faq/index");
} else {
die('Oops some thing wrong!!.');
}
}
}
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/index');
}
} else {
$this->_redirect('admin/index/index');
}
}
}