| 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/indoasiaholidays.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 : Ranvir Singh <ranvir@catpl.co.in>
* Created Date : 23 May 2017
* Updated Date : 23 May 2017
***************************************************************/
class Admin_OfficesController 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/offices/';
$this->img_w_small = 120;
$this->img_h_small = 120;
$this->DIR_WRITE_MODE = 0777;
$this->table = 'tbl_my_offices';
}
/**
* index() method is used to admin login for form call
* @param Null
* @return Array
*/
public function indexAction()
{
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$resultset = $crud->rv_select_all($this->table, ['*'], ['status'=>1], ['officeType'=>'ASC','officeOrder'=>'ASC']);
# Start : Pagination
$page = $this->_getParam('page', 1);
$resultset = Zend_Paginator::factory($resultset);
$resultset->setItemCountPerPage($this->per_page_record);
$resultset->setCurrentPageNumber($page);
# End : Pagination
$this->view->page = $page;
$this->view->per_page_record = $this->per_page_record;
$this->view->resultset = $resultset;
$this->view->result_destination = $result_destination;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
/**
* editpage() method is used to admin can edit cms static page
* @param password string
* @return ture
*/
public function editofficesAction()
{
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editoffices();
$pId = (int)$this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/offices/editoffices/id/".$pId);
$form->setName("editoffices");
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;
$AboutId = $getData['officeId'];
$orignalFIleName = $image = $_FILES["officeImage"]["name"];
if (!empty($orignalFIleName)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl ;
$fileExt = $this->_helper->General->getFileExtension($orignalFIleName);
$fileName = $this->current_time . '.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["officeImage"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
if($fileName!=""){
$image_edit = $fileName;
}
$editPageData = [
'officeTitle' => ($getData['officeTitle']),
'officeEmail' => ($getData['officeEmail']),
'officePhone' => ($getData['officePhone']),
'officeAddress' => ($getData['officeAddress']),
'CreateDate'=> date('Y-m-d H:i:s'),
'status' => ($getData['status']),
'officeType' => ($getData['officeType']),
'officeOrder' => (int)($getData['officeOrder']),
'officeDirection' => ($getData['officeDirection']),
];
if( $image_edit) {
$editPageData['officeImage'] = $image_edit;
}
// echo "<pre>";print_r($editPageData);die;
$crud->rv_update($this->table, $editPageData, ['officeId =?'=>$AboutId]);
$this->view->successMessage ="Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/offices/index");
}
}
}
$result = $crud->getCmsdata($this->table, ['*'], ['officeId'=>$pId], ['officeId'=>'DESC']);
// echo "<pre>";print_r($result);die;
$editdata["officeId"] = @$result->officeId;
$editdata["officeTitle"] = @$result->officeTitle;
$editdata["officeEmail"] = @$result->officeEmail;
$editdata["officePhone"] = @$result->officePhone;
$editdata["officeImage"] = @$result->officeImage;
$editdata["officeAddress"] = @$result->officeAddress;
$editdata["status"] = @$result->status;
$editdata["officeType"] = @$result->officeType;
$editdata["officeOrder"] = @$result->officeOrder;
$editdata["officeDirection"] = @$result->officeDirection;
// echo "<pre>";print_r($editdata);die;
$form->populate($editdata);
$this->view->officeImage = @$result->officeImage;
$this->view->form = $form;
}
public function addofficesAction()
{
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editoffices();
$pId = (int)$this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/offices/addoffices");
$form->setName("editoffices");
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;
$orignalFIleName = $image = $_FILES["officeImage"]["name"];
if (!empty($orignalFIleName)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl ;
$fileExt = $this->_helper->General->getFileExtension($orignalFIleName);
$fileName = $this->current_time . '.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["officeImage"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
if($fileName!=""){
$image_add = $fileName;
}else {
$image_add = "";
}
// $BlogDate1 = explode('/', $getData['BlogDate']);
// $BlogDate = $BlogDate1[2]."-".$BlogDate1[1]."-".$BlogDate[0];
$savePageData = [
'officeTitle' => ($getData['officeTitle']),
'officeEmail' => ($getData['officeEmail']),
'officePhone' => ($getData['officePhone']),
'officeImage' => $image_add,
'officeAddress' => ($getData['officeAddress']),
'CreateDate'=> date('Y-m-d H:i:s'),
'status' => ($getData['status']),
'officeType' => ($getData['officeType']),
'officeOrder' => (int)($getData['officeOrder']),
'officeDirection' => ($getData['officeDirection']),
];
// 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/offices/index");
}
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function deleteofficesAction() {
$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, ['officeId'], ['officeId' => $tId], ['officeId' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete($this->table, ['officeId =?'=>$tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/offices/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');
}
}
}