| 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/tripsgateway/application/admin/controllers/ |
Upload File : |
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : ContactusController.php
* File Desc. : Contactus controller managed all contact queries
* Created By : Ranvir Singh <twitter @ranvir2012>
* Created Date : 23 May 2017
* Updated Date : 23 May 2017
***************************************************************/
class Admin_InclusionController extends Zend_Controller_Action
{
public $dbAdapter;
public $perPageLimit;
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/inclusion/';
$this->imageUrl1 = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/explore/';
$this->imageUrl2 = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/explore/images/';
$this->documentRoot = "/var/www/html/tripsgateway";
$this->img_w_small = 120;
$this->img_h_small = 120;
$this->DIR_WRITE_MODE = 0777;
$this->table = "tbl_inclusion_icon";
}
/**
* 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'],['Title' => 'ASC']);
// echo "<pre>";print_r($resultset);die;
# 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->messages = $this->_helper->flashMessenger->getMessages();
}
public function editinclusionAction(){
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Editinclusion();
$pId = (int)$this->getRequest()->getParam("id");
$form->setMethod("POST");
$form->setAction("admin/inclusion/editinclusion/id/".$pId);
$form->setName("edit_inclusion");
if( $this->getRequest()->isPost() ) {
$getData = $this->getRequest()->getPost();
if($form->isValid($getData)) {
//-------Start Code for Approve and Publish content---------//
if(isset($getData['save'])=="Save") {
// $result = $crud->getCmsdata($this->table, ['*'], ['status'], ['id' => 'DESC']);
$images = $_FILES['Icon']['name'];
if (!empty($images)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl ;
$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["Icon"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
if($fileName!=""){
$image_edit = $fileName;
}
$editPageData = [
'label'=>($getData['Title']),
'status'=>"{$getData['status']}"
];
if($fileName){
$editPageData['Icon'] = $image_edit;
}
// echo "<pre>";print_r($editPageData);die;
$crud->rv_update($this->table, $editPageData, ['id =?'=>$pId]);
$this->view->successMessage ="Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been updated successfully.");
$this->_redirect("/admin/inclusion/index");
}
}
}
$result = $crud->getCmsdata($this->table, ['*'], ['id'=>$pId], ['id'=>'DESC']);
// echo "<pre>";print_r($result);die;
$editdata["id"] = @$result->id;
$editdata["Title"] = @$result->label;
$editdata["Icon"] .= @$result->Icon;
$editdata["status"] = @$result->status;
$form->populate($editdata);
$this->view->Icon .= @$result->Icon;
$this->view->form = $form;
//die('ok');
}
public function addinclusionAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Addinclusion();
$tId = (int)$this->getRequest()->getParam("id");
$form->setAction("admin/inclusion/addinclusion");
$form->setMethod("POST");
$form->setName("add_inclusion");
if( $this->getRequest()->isPost() ) {
$getData = $this->getRequest()->getPost();
if($form->isValid($getData)) {
if(isset($getData['save'])=="Save") {
// $target_dir = "public/upload/inclusion/";
// $target_file = $target_dir . basename($_FILES["Icon"]["name"]);
//
// $uploadOk = 1;
// if (move_uploaded_file($_FILES["Icon"]["tmp_name"], $target_file)) {
// "The file " . basename($_FILES["Icon"]["name"]) . " has been uploaded.";
// }
$fileName = '';
$images = $_FILES["Icon"]["name"];
if (!empty($images)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl ;
$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["Icon"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
$savePageData = [
'Title'=>($getData['Title']),
'Icon'=>($fileName),
'status'=>$getData['status']
];
$crud->rv_insert($this->table, $savePageData);
$this->view->successMessage ="Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been added successfully.");
$this->_redirect("/admin/inclusion/index");
}
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function deleteinclusionAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int)$this->getRequest()->getParam("id");
if($tId){
$checkdata = $crud->rv_select_row($this->table, ['id'], ['id'=>$tId], ['id'=>'asc']);
if(count($checkdata)>0){
$crud->rv_delete($this->table, ['id =?'=>$tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/inclusion/index");
}else{
die('Oops some thing wrong!!.');
}
}
}
public function exploreAction()
{
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$resultset = $crud->rv_select_all("tbl_explore_icon", ['*'], ['status'],['Title' => 'ASC']);
// echo "<pre>";print_r($resultset);die;
# 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->messages = $this->_helper->flashMessenger->getMessages();
}
public function addexploreiconAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int)$this->getRequest()->getParam("id");
if( $this->getRequest()->isPost() ) {
$getData = $this->getRequest()->getPost();
if(isset($getData['save'])=="Save") {
// $target_dir = "public/upload/inclusion/";
// $target_file = $target_dir . basename($_FILES["Icon"]["name"]);
//
// $uploadOk = 1;
// if (move_uploaded_file($_FILES["Icon"]["tmp_name"], $target_file)) {
// "The file " . basename($_FILES["Icon"]["name"]) . " has been uploaded.";
// }
$fileName = '';
$images = $_FILES["Icon"]["name"];
if (!empty($images)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl1 ;
$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["Icon"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
$fileName1 = '';
$exploreImage1 = $_FILES["exploreImage1"]["name"];
if (!empty($exploreImage1)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl1 ;
$fileExt = $this->_helper->General->getFileExtension($exploreImage1);
$fileName1 = $this->current_time . '.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["exploreImage1"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName1);
}
$savePageData = [
'Title'=>($getData['Title']),
'destination'=>($getData['destination']),
'Icon'=>($fileName),
'exploreImage1'=>($fileName1),
'status'=>$getData['status']
];
//echo"<pre>"; print_r($savePageData); die();
$crud->rv_insert("tbl_explore_icon", $savePageData);
$this->view->successMessage ="Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been added successfully.");
$this->_redirect("/admin/inclusion/explore");
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function editexploreiconAction(){
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
//$form = new Admin_Form_Editinclusion();
$pId = (int)$this->getRequest()->getParam("id");
//$form->setMethod("POST");
//$form->setAction("admin/inclusion/editexploreicon/id/".$pId);
//$form->setName("edit_exploreicon");
if( $this->getRequest()->isPost() ) {
$getData = $this->getRequest()->getPost();
//if($form->isValid($getData)) {
//-------Start Code for Approve and Publish content---------//
if(isset($getData['save'])=="Save") {
// $result = $crud->getCmsdata($this->table, ['*'], ['status'], ['id' => 'DESC']);
$images = $_FILES['Icon']['name'];
if (!empty($images)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl1 ;
$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["Icon"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
if($fileName!=""){
$image_edit = $fileName;
}
$exploreImage1 = $_FILES['exploreImage1']['name'];
if (!empty($exploreImage1)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl2 ;
$fileExt = $this->_helper->General->getFileExtension($exploreImage1);
$fileName1 = $this->current_time . '_1.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["exploreImage1"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName1);
}
if($fileName1!=""){
$exploreImage1_edit = $fileName1;
}
$exploreImage2 = $_FILES['exploreImage2']['name'];
if (!empty($exploreImage2)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl2 ;
$fileExt = $this->_helper->General->getFileExtension($exploreImage2);
$fileName2 = $this->current_time . '_2.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["exploreImage2"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName2);
}
if($fileName2!=""){
$exploreImage2_edit = $fileName2;
}
$exploreImage3 = $_FILES['exploreImage3']['name'];
if (!empty($exploreImage3)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl2 ;
$fileExt = $this->_helper->General->getFileExtension($exploreImage3);
$fileName3 = $this->current_time . '_3.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["exploreImage3"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName3);
}
if($fileName3!=""){
$exploreImage3_edit = $fileName3;
}
$exploreImage4 = $_FILES['exploreImage4']['name'];
if (!empty($exploreImage4)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl2 ;
$fileExt = $this->_helper->General->getFileExtension($exploreImage4);
$fileName4 = $this->current_time . '_4.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["exploreImage4"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName4);
}
if($fileName4!=""){
$exploreImage4_edit = $fileName4;
}
$exploreImage5 = $_FILES['exploreImage5']['name'];
if (!empty($exploreImage5)) {
$orignalFolderName = $this->documentRoot . "/" . $this->imageUrl2 ;
$fileExt = $this->_helper->General->getFileExtension($exploreImage5);
$fileName5 = $this->current_time . '_5.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["exploreImage5"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName5);
}
if($fileName5!=""){
$exploreImage5_edit = $fileName5;
}
$editPageData = [
'Title'=>($getData['Title']),
'destination'=>($getData['destination']),
'status'=>"{$getData['status']}"
];
if($fileName){
$editPageData['Icon'] = $image_edit;
}
if($fileName1){
$editPageData['exploreImage1'] = $exploreImage1_edit;
}
if($fileName2){
$editPageData['exploreImage2'] = $exploreImage2_edit;
}
if($fileName3){
$editPageData['exploreImage3'] = $exploreImage3_edit;
}
if($fileName4){
$editPageData['exploreImage4'] = $exploreImage4_edit;
}
if($fileName5){
$editPageData['exploreImage5'] = $exploreImage5_edit;
}
// echo "<pre>";print_r($editPageData);die;
$crud->rv_update("tbl_explore_icon", $editPageData, ['id =?'=>$pId]);
$this->view->successMessage ="Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been updated successfully.");
$this->_redirect("/admin/inclusion/explore");
//}
}
}
$result = $crud->getCmsdata("tbl_explore_icon", ['*'], ['id'=>$pId], ['id'=>'DESC']);
$resultOtherlocationcity= $crud->getCityListByCityArrayIds($result->destination);
// echo "<pre>";print_r($result);die;
$editdata["id"] = @$result->id;
$editdata["Title"] = @$result->Title;
$editdata["Icon"] .= @$result->Icon;
$editdata["exploreImage1"] .= @$result->exploreImage1;
$editdata["exploreImage2"] .= @$result->exploreImage2;
$editdata["exploreImage3"] .= @$result->exploreImage3;
$editdata["exploreImage4"] .= @$result->exploreImage4;
$editdata["exploreImage5"] .= @$result->exploreImage5;
$editdata["destination"] .= @$result->destination;
$editdata["status"] = @$result->status;
$this->view->Icon = @$result->Icon;
$this->view->exploreImage1 = @$result->exploreImage1;
$this->view->exploreImage2 = @$result->exploreImage2;
$this->view->exploreImage3 = @$result->exploreImage3;
$this->view->exploreImage4 = @$result->exploreImage4;
$this->view->exploreImage5 = @$result->exploreImage5;
$this->view->resultOtherlocationcity = $resultOtherlocationcity;
$this->view->editdata = $editdata;
//die('ok');
//echo "<pre>";print_r($editdata);die;
}
public function deleteexploreiconAction(){
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int)$this->getRequest()->getParam("id");
if($tId){
$checkdata = $crud->rv_select_row("tbl_explore_icon", ['id'], ['id'=>$tId], ['id'=>'asc']);
if(count($checkdata)>0){
$crud->rv_delete("tbl_explore_icon", ['id =?'=>$tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/inclusion/explore");
}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');
}
}
}