| 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/travelbrace.com/application/admin/controllers/ |
Upload File : |
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : HomePromotionController.php
* File Desc. : HomePromotion Controller managed all Home Promotion content pages
* Created By : Mangal katiyar <mangal.co.in>
* Created Date : 19 Nov 2018
* Updated Date : 19 Nov 2018
***************************************************************/
class Admin_WebsitesController 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;
$options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('bootstrap');
$this->gtxagencysysid = $options['gtxagencysysid'];
$this->stylecss = $options['stylecss'];
$this->current_time = time();
$this->promoimageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/'.$this->stylecss.'/websites/';
$this->DIR_WRITE_MODE = 0777;
$this->table = 'tbl_home_promotion';
$this->large_image_width = $aConfig['bootstrap']['large_image_width'];
$this->large_image_height = $aConfig['bootstrap']['large_image_height'];
$this->medium_image_width = $aConfig['bootstrap']['medium_image_width'];
$this->medium_image_height = $aConfig['bootstrap']['medium_image_height'];
$this->small_image_width = $aConfig['bootstrap']['small_image_width'];
$this->small_image_height = $aConfig['bootstrap']['small_image_height'];
}
public function indexAction()
{
$this->checklogin();
$crud = new Admin_Model_CRUD();
if( $this->getRequest()->isPost() ) {
$getData = $this->getRequest()->getPost();
//echo "<pre>";print_r($getData);die;
if($getData) {
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
$pId = $getData['home_common_id'];
$PopupCheck = isset($getData['PopupCheck']) ? trim($getData['PopupCheck']) : '';
$SearchList = isset($getData['SearchList']) ? trim($getData['SearchList']) : '';
$DetailPage = isset($getData['DetailPage']) ? trim($getData['DetailPage']) : '';
$HeaderBG = isset($getData['HeaderBG']) ? trim($getData['HeaderBG']) : '';
$Header2BG = isset($getData['Header2BG']) ? trim($getData['Header2BG']) : '';
$ButtonColor = isset($getData['ButtonColor']) ? trim($getData['ButtonColor']) : '';
$HeaderFontColor = isset($getData['HeaderFontColor']) ? trim($getData['HeaderFontColor']) : '';
$MenuFontColor = isset($getData['MenuFontColor']) ? trim($getData['MenuFontColor']) : '';
$FooterBG = isset($getData['FooterBG']) ? trim($getData['FooterBG']) : '';
$FooterFontColor = isset($getData['FooterFontColor']) ? trim($getData['FooterFontColor']) : '';
$Footer2BG = isset($getData['Footer2BG']) ? trim($getData['Footer2BG']) : '';
$Footer2FontColor = isset($getData['Footer2FontColor']) ? trim($getData['Footer2FontColor']) : '';
$BackgroundColor = isset($getData['BackgroundColor']) ? trim($getData['BackgroundColor']) : '';
$mainFontColor = isset($getData['mainFontColor']) ? trim($getData['mainFontColor']) : '';
$slogan = isset($getData['slogan']) ? trim($getData['slogan']) : '';
$defaultName = array('logo','mainbanner','placeholder');
$imagearray = '';
foreach($_FILES["DefaultImages"]["tmp_name"] as $index => $temp_name){
$_FILES["DefaultImages"]["name"][$index];
$_FILES["DefaultImages"]["size"][$index];
if (!empty($_FILES["DefaultImages"]["name"][$index])) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->promoimageUrl;
$fileExtion = $this->_helper->General->getFileExtension($_FILES["DefaultImages"]["name"][$index]);
$bfileName = $defaultName[$index].'.'.$fileExtion;
$allowedExtensions = ['jpg', 'jpeg', 'png', 'webp'];
if(in_array($fileExtion, $allowedExtensions, true)){
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["DefaultImages"]["tmp_name"][$index]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $bfileName);
}else {
$this->view->errorMessage ="Only allow 'jpg', 'png', 'webp' ";
}
if ($imagearray) $imagearray .= ',';
$imagearray .=$bfileName;
}else{
if ($imagearray) $imagearray .= ',';
$imagearray .=$getData['saveDefaultImages'][$index];
}
}
$imagesdata = explode(',',$imagearray);
$webThemeSettings = json_encode(array('PopupCheck'=>$PopupCheck, 'SearchList'=>$SearchList, 'DetailPage'=>$DetailPage, 'DefaultImages'=>$imagearray, 'slogan'=>$slogan));
$webColorSettings = json_encode(array('HeaderBG'=>$HeaderBG, 'Header2BG'=>$Header2BG, 'ButtonColor'=>$ButtonColor, 'HeaderFontColor'=>$HeaderFontColor, 'MenuFontColor'=>$MenuFontColor, 'FooterBG'=>$FooterBG, 'FooterFontColor'=>$FooterFontColor, 'Footer2BG'=>$Footer2BG, 'Footer2FontColor'=>$Footer2FontColor, 'BackgroundColor'=>$BackgroundColor, 'mainFontColor'=>$mainFontColor));
$editPageData = [
'block1' =>$webThemeSettings,
'block2' =>$webColorSettings,
'status' =>1
];
$prom_cat_id=$crud->rv_update('tbl_websites_setting', $editPageData, ['AgencySysId =?' =>$this->gtxagencysysid]);
$css_response = ':root {
--mainbackgroundcolor: '.$BackgroundColor.';
--mainfontcolor: '.$mainFontColor.';
--maincolor: '.$ButtonColor.';
--bg-header-top-menu: '.$HeaderBG.';
--text-header-top-menu: '.$HeaderFontColor.';
--bg-header-menu: '.$Header2BG.';
--text-header-menu: '.$MenuFontColor.';
--bg-footer1: '.$FooterBG.';
--text-footer1: '.$FooterFontColor.';
--bg-footer2: '.$Footer2BG.';
--text-footer2:'.$Footer2FontColor.';
}';
$CSSFileName = "public/upload/".$this->stylecss."/websites/settings.css";
if (!file_exists("public/upload/".$this->stylecss."/websites/")) {
mkdir("public/upload/".$this->stylecss."/websites/", 0777, true);
}
file_put_contents($CSSFileName, $css_response);
}
}
$this->view->successMessage = "Page content has been updated successfully.";
}
$result = $crud->getCmsdata('tbl_websites_setting', ['*'], ['AgencySysId' =>$this->gtxagencysysid], ['home_common_id'=>'DESC']);
$block1 = json_decode($result->block1,1);
$block2 = json_decode($result->block2,1);
$editdata["home_common_id"] = $result->home_common_id;
$editdata["PopupCheck"] = $block1['PopupCheck'];
$editdata["SearchList"] = $block1['SearchList'];
$editdata["DetailPage"] = $block1['DetailPage'];
$editdata["slogan"] = $block1['slogan'];
$editdata["DefaultImages"] = explode(',', $block1['DefaultImages']);
$editdata["HeaderBG"] = $block2['HeaderBG'];
$editdata["Header2BG"] = $block2['Header2BG'];
$editdata["ButtonColor"] = $block2['ButtonColor'];
$editdata["HeaderFontColor"] = $block2['HeaderFontColor'];
$editdata["MenuFontColor"] = $block2['MenuFontColor'];
$editdata["FooterBG"] = $block2['FooterBG'];
$editdata["FooterFontColor"] = $block2['FooterFontColor'];
$editdata["Footer2BG"] = $block2['Footer2BG'];
$editdata["Footer2FontColor"] = $block2['Footer2FontColor'];
$editdata["BackgroundColor"] = $block2['BackgroundColor'];
$editdata["mainFontColor"] = $block2['mainFontColor'];
$this->view->editdata = $editdata;
//echo "<pre>";print_r($editdata);die;
}
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');
}
}
}