| 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/b2c.hellogtx.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_FaqController extends Zend_Controller_Action {
public $dbAdapter;
public $perPageLimit;
public $siteurl;
public $DIR_WRITE_MODE;
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 = 20;
$this->dbAdapter = Zend_Db_Table::getDefaultAdapter();
$auth = Zend_Auth::getInstance();
$authStorage = $auth->getStorage()->read();
$this->username = $authStorage->username;
$this->admin_type = $authStorage->role;
$this->current_time = time();
$this->imageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/travelogues/';
$this->imageUrl1 = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/thingstodo/category/';
$this->imageUrl2 = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/thingstodo/';
$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->DIR_WRITE_MODE = 0777;
$this->table = 'tbl_btpfaq';
//$this->commenttable = 'tbl_comments';
//$_SERVER["DOCUMENT_ROOT"] = $_SERVER["DOCUMENT_ROOT"].'/holidaybazaar';
}
/**
* index() method is used to admin login for form call
* @param Null
* @return Array
*/
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($this->table, ['isMarkForDel' => 0], 'FaqId');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_all($this->table, ['FaqId', 'FaqTitle', 'FaqDescription', 'displayOnHome'], ['isMarkForDel' => 0], ['FaqId' => 'DESC']);
//print_r($resultset);die;
$resultsetArr = array();
foreach ($resultset as $key => $value) {
$resultsetArr[] = [
'FaqId' => $value['FaqId'],
'FaqTitle' => $value['FaqTitle'],
'FaqDescription' => $value['FaqDescription'],
'displayOnHome' => $value['displayOnHome'],
];
}
$result = Zend_Json::encode($resultsetArr);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['FaqId'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function editfaqAction() {
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editfaq();
$pId = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/faq/editfaq/id/" . $pId);
$form->setName("edit_travelogues");
;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if ($form->isValid($getData)) {
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
// echo "<pre>";print_r($getData);die;
//Code for check page alias name already exists or not
$FaqId = $getData['FaqId'];
$editPageData = [
'FaqTitle' => ($getData['FaqTitle']),
'FaqDescription' => ($getData['FaqDescription']),
];
// echo "<pre>"; print_r($editPageData); die;
$crud->rv_update($this->table, $editPageData, ['FaqId =?' => $FaqId]);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/faq/index");
}
}
}
$result = $crud->getCmsdata($this->table, ['*'], ['FaqId' => $pId], ['FaqId' => 'DESC']);
// echo "<pre>";print_r($result);die;
$editdata["FaqId"] = @$result->FaqId;
$editdata["FaqTitle"] = @$result->FaqTitle;
$editdata["FaqDescription"] = @$result->FaqDescription;
//echo "<pre>";print_r($editdata);die;
$form->populate($editdata);
$this->view->FaqId = @$result->FaqId;
$this->view->FaqTitle = @$result->FaqTitle;
$this->view->FaqDescription = @$result->FaqDescription;
$this->view->form = $form;
}
public function addfaqAction() {
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Addfaq();
$pId = (int) $this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/faq/addfaq");
$form->setName("add_thingstodo");
$lastRow = $crud->getCmsdata($this->table, ['FaqId'], ['FaqId'], ['FaqId' => 'DESC']);
$FaqId = $lastRow['FaqId'] + 1;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if ($form->isValid($getData)) {
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
// echo "<pre>";print_r($getData);die;
$savePageData = [
'FaqTitle' => ($getData['FaqTitle']),
'FaqDescription' => ($getData['FaqDescription']),
'displayOnHome' => 1,
'isMarkForDel' => 0,
];
// echo "<pre>";print_r($savePageData);die;
$crud->rv_insert($this->table, $savePageData);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been added successfully.");
$this->_redirect("/admin/faq/index");
}
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$this->view->resultsetPackage = $resultsetPackage;
$this->view->resultsetTravelogues = $resultsetTravelogues;
$this->view->getCategory = $resultCategory;
}
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($this->table, ['FaqId'], ['FaqId' => $tId], ['FaqId' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete($this->table, ['FaqId =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Deleted successfully.");
$this->_redirect("/admin/faq/index");
} else {
die('Oops some thing wrong!!.');
}
}
}
// public function activebAction() {
// $this->checklogin();
// $crud = new Admin_Model_CRUD();
// $tId = (int) $this->getRequest()->getParam("id");
// $val = (int) $this->getRequest()->getParam("val");
// if ($tId) {
// try {
// $updatedata = [
// 'displayOnBanner' => $val
// ];
// $result = $crud->rv_update('tbl_thingstodo', $updatedata, ['TravId =?' => $tId]);
// $resultset = $crud->rv_select_all("tbl_thingstodo", ['*'], ['displayOnBanner' => 1, 'status' => 1, 'isMarkForDel' => 0], ['TravId' => 'ASC']);
// 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 activebAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
$val = (int) $this->getRequest()->getParam("val");
if ($tId) {
try {
$updatedata = [
'displayOnHome' => $val
];
$result = $crud->rv_update('tbl_btpfaq', $updatedata, ['FaqId =?' => $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 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');
}
}
public function selectimageAction() {
$this->view->layout()->disableLayout();
$folder = $this->getRequest()->getParam("folder");
$dir_name = "public/upload/travelogues/descriptionimage/" . $folder;
$descriptionimages = glob($dir_name . "*");
$this->view->descriptionimages = $descriptionimages;
$this->view->siteurl = $this->siteurl;
// echo "";print_r($descriptionimages);die;
}
public function uploadImageAction() {
// $filename = $_FILES['file']['name'];
$orignalFIleName = $_FILES["file"]["name"];
if (!empty($orignalFIleName)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . '/' . $this->imageUrl;
$originalSmallFolder = $orignalFolderName . "/descriptionimage";
$fileExt = $this->_helper->General->getFileExtension($orignalFIleName);
$fileName = 'descriptionimage_' . time() . '.' . $fileExt;
if (!file_exists($orignalFolderName)) {
@mkdir($orignalFolderName, 0777, true);
}
if (!file_exists($originalSmallFolder)) {
@mkdir($originalSmallFolder, 0777, true);
}
$temp_file_name = $_FILES["file"]["tmp_name"]; // temprary file name
if (move_uploaded_file($temp_file_name, $originalSmallFolder . "/" . $fileName)) {
$imageUrl = $this->siteurl . 'public/upload/travelogues/descriptionimage/' . $fileName;
$fileArray = array('status' => 'success', 'fileName' => $fileName, 'imageUrl' => $imageUrl);
}
}
echo json_encode($fileArray);
exit;
}
}