| 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 : 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_OurteamsController extends Zend_Controller_Action {
public $dbAdapter;
public $perPageLimit;
public function init() {
/* Initialize db and session access */
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->view->siteurl = $this->siteurl = $aConfig['bootstrap']['siteUrl'];
$this->view->stylecss = $this->stylecss = $aConfig['bootstrap']['stylecss'];
$this->appmode = $aConfig['bootstrap']['appmode'];
$this->per_page_record = 10;
$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/'.$this->stylecss.'/ourteams/';
$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('tbl_ourpartner', ['*'],['isMarkForDel' =>0 ], ['id' => '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->resultset = $resultset;
$this->view->per_page_record = $this->per_page_record;
$this->view->page = $page;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function editourteamsAction(){
//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/ourteams/editourteams/id/" . $pId);
$form->setName("edit_ourteams");
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'];
// echo $images;die;
// $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.";
// }
if (!empty($images)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $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;
}
$designation = isset($getData['designation']) ? trim($getData['designation']) : '';
$phone = isset($getData['phone']) ? trim($getData['phone']) : '';
$email = isset($getData['email']) ? trim($getData['email']) : '';
$description = isset($getData['description']) ? trim($getData['description']) : '';
$url = isset($getData['url']) ? trim($getData['url']) : 0;
$adddescription = json_encode(array('designation'=>$designation,'phone'=>$phone,'email'=>$email,'description'=>$description));
$editPageData = [
'Title' => $getData['Title'],
'description' => $adddescription,
'url' => $url,
'tab' => ($getData['tab']),
'status' => "{$getData['status']}",
'isMarkForDel' => 0,
];
if ($fileName) {
$editPageData['Icon'] = $image_edit;
}
// echo "<pre>";print_r($editPageData);die;
$crud->rv_update('tbl_ourpartner', $editPageData, ['id =?' => $pId]);
$this->view->successMessage = "Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been updated successfully.");
$this->_redirect("/admin/ourteams/index");
}
}
}
$result = $crud->getCmsdata('tbl_ourpartner', ['*'], ['id' => $pId], ['id' => 'DESC']);
// echo "<pre>";print_r($result);die;
$editdata["id"] = @$result->id;
$editdata["Title"] = @$result->title;
$editdata["description"] = @$result->description;
$editdata["Icon"] = @$result->icon;
$editdata["url"] = @$result->url;
$editdata["tab"] = @$result->tab;
$editdata["status"] = @$result->status;
// echo "<pre>";print_r($editdata);die;
$form->populate($editdata);
$this->view->url .= @$result->url;
$this->view->getdescription .= @$result->description;
$this->view->tab .= @$result->tab;
$this->view->Icon .= @$result->icon;
$this->view->form = $form;
}
public function addourteamsAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Addinclusion();
$tId = (int) $this->getRequest()->getParam("id");
$form->setAction("admin/ourteams/addourteams");
$form->setMethod("POST");
$form->setName("add_ourteams");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if ($form->isValid($getData)) {
if (isset($getData['save']) == "Save") {
// echo"<pre>";print_r($getData);die;
// $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.";
// }
$images = $_FILES["Icon"]["name"];
if (!empty($images)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $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);
}
$designation = isset($getData['designation']) ? trim($getData['designation']) : '';
$phone = isset($getData['phone']) ? trim($getData['phone']) : '';
$email = isset($getData['email']) ? trim($getData['email']) : '';
$description = isset($getData['description']) ? trim($getData['description']) : '';
$url = isset($getData['url']) ? trim($getData['url']) : 0;
$adddescription = json_encode(array('designation'=>$designation,'phone'=>$phone,'email'=>$email,'description'=>$description));
$savePageData = [
'Title' =>$getData['Title'],
'description' => $adddescription,
'Icon' => ($fileName),
'url' => $url,
'tab' => (int)($getData['tab']),
'status' => $getData['status'],
'isMarkForDel' => 0,
];
$crud->rv_insert('tbl_ourpartner', $savePageData);
$this->view->successMessage = "Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been added successfully.");
$this->_redirect("/admin/ourteams/index");
}
}
}
$this->view->form = $form;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function deleteourteamsAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
if ($tId) {
$checkdata = $crud->rv_select_row('tbl_ourpartner', ['id'], ['id' => $tId], ['id' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_update('tbl_ourpartner', ['isMarkForDel'=> 1], ['id =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Deleted successfully.");
$this->_redirect("/admin/ourteams/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');
}
}
}