File: /home/barbeatleanalyti/public_html/beatleanalytics.com/application/controllers/Beatle.php-20-05-22
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Beatle extends CI_Controller {
public function __construct()
{
$dataa = array();
parent::__construct();
// load library form validation
$this->load->library('form_validation');
$this->load->helper('url');
$this->load->model('AdminModel');
$this->load->model('BeatleModel');
$this->load->library('pagination');
$this->load->library('email');
$this->session->keep_flashdata('success','error');
// $this->session->keep_flashdata('error');
$this->allblog = json_decode($this->AdminModel->getallblog());
$this->alltag = $this->AdminModel->getalltag();
//$this->load->model('AdminModel');
// load beatle live database here
$this->beatle_live = $this->load->database('beatle_live', TRUE);
//echo '<pre>'; print_r($this->beatle_live); die;
// end here
}
// Index function start here
public function index()
{
//$getlistbytype = $this->BeatleModel->getlistbytype();
//echo '<pre>'; print_r($this->alltag);die;
$getlisting = $this->BeatleModel->getallilsting();
$getallclub = $this->BeatleModel->getallclub();
$getallgym = $this->BeatleModel->getallgym();
$getallrestaurant = $this->BeatleModel->getallrestaurant();
$getallHotel = $this->BeatleModel->getallHotel();
// echo '<pre>'; print_r($getallrestaurant);die;
$data = array
(
'getalltag' => $this->alltag,
'getlisting' => json_decode($getlisting),
'Club' => $getallclub,
'Restaurant' => $getallrestaurant,
'Hotel' => $getallHotel,
'Gym' => $getallgym
);
$this->load->view('beatle/index',$data);
}
// Login page start here
public function login()
{
$data = array('getalltag'=>$this->alltag);
$this->load->view('beatle/login',$data);
}
// end here
//About Us function start here
public function aboutus()
{
$data = array('getalltag'=>$this->alltag);
$this->load->view('beatle/aboutus',$data);
}
public function PrivacyPolicy()
{
$data = array('getalltag'=>$this->alltag);
$this->load->view('beatle/privacypolicy',$data);
}
//News function start here
public function news()
{
//config for bootstrap pagination class integration
$config = array();
$config["base_url"] = FRONTRND_URL. "news";
$total_row = $this->BeatleModel->getallnewscount();
$config["total_rows"] = $total_row;
$config["per_page"] = 6;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = ' <a class="page-numbers active">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = '<lable class="page-numbers next ml-sm-5 ml-3"> <i class="fa fa-angle-right"></i></lable>';
$config['prev_link'] = '<lable class="page-numbers prev mr-sm-5 mr-3"><i class="fa fa-angle-left"></i></lable>';
$config['num_tag_open'] = ' <a class="page-numbers">';
$config['num_tag_close'] = '</a>';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["links"] = $this->pagination->create_links();
$data['getallnews'] = $this->BeatleModel->getallnewslimit($config["per_page"], $page);
$data['getalltag'] = $this->alltag;
//echo '<pre>'; print_r($data); die;
$this->load->view('beatle/news',$data);
}
// News Details acc News Id
public function newsDetail()
{
$newsid = base64_decode($this->uri->segment(4));
$newsDetail = $this->AdminModel->getNewsAccId($newsid);
$newsjson = json_decode($newsDetail);
//echo '<pre>'; print_r(json_decode($newsDetail));
$preview = $newsjson[0]->news_view;
$view = ++$preview;
$udpatearr = array('news_view'=>$view);
$updateview = $this->db->where('id',$newsid)->update('beatle_news',$udpatearr);
//echo $view;
$getallNews = $this->AdminModel->getallNews();
//$getallblog = $this->AdminModel->getallblog();
$allnewsid = array();
foreach (json_decode($getallNews) as $k=>$v){
$allnewsid[] = $v->id;
}
//echo '<pre>'; print_r($allblogid);
$prevval = '';
$nextval = '';
$index = array_search($newsid, $allnewsid);
if($index !== false && $index > 0 ) $prevval = $allnewsid[$index-1];
if($index !== false && $index < count($allnewsid)-1) $nextval = $allnewsid[$index+1];
if (!empty($prevval)){$prev = $prevval;} else {$prev = current($allnewsid);}
if (!empty($nextval)){$next = $nextval;} else {$next = current($allnewsid);}
$data = array
(
'newsDetail'=> json_decode($newsDetail),
'getallNews'=> json_decode($getallNews),
'prevval' => $prev,
'nextval' => $next,
'getalltag' => $this->alltag
);
//echo '<pre>'; print_r($data); die;
$this->load->view('beatle/newsdetails',$data);
}
//Blog function start here
public function blog()
{
//config for bootstrap pagination class integration
$config = array();
$config["base_url"] = FRONTRND_URL. "blog";
$total_row = $this->BeatleModel->getallblogcount();
$config["total_rows"] = $total_row;
$config["per_page"] = 6;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = ' <a class="page-numbers active">';
$config['cur_tag_close'] = '</a>';
$config['num_tag_open'] = ' <a class="page-numbers">';
$config['num_tag_close'] = '</a>';
$config['next_link'] = '<lable class="page-numbers next ml-sm-5 ml-3"><i class="fa fa-angle-right"></i></lable>';
$config['prev_link'] = '<lable class="page-numbers prev mr-sm-5 mr-3"><i class="fa fa-angle-left"></i></lable>';
$this->pagination->initialize($config);
// echo '<pre>'; print_r($this->pagination->initialize($config));die;
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["links"] = $this->pagination->create_links();
$data['getallblog'] = $this->BeatleModel->getallbloglimit($config["per_page"], $page);
$data['getalltag'] = $this->alltag;
// echo '<pre>'; print_r($data); die;
$this->load->view('beatle/blog',$data);
}
//Blog function start here
// blog Details page start here
public function blogDetails()
{
$blogid = base64_decode($this->uri->segment(4));
$titleurl = $this->uri->segment(3);
$getallblog = $this->AdminModel->getallblog();
$allblogid = array();
foreach (json_decode($getallblog) as $k=>$v){
$allblogid[] = $v->id;
}
//echo '<pre>'; print_r($allblogid);
$index = array_search($blogid, $allblogid);
if($index !== false && $index > 0 ) $prevval = $allblogid[$index-1];
if($index !== false && $index < count($allblogid)-1) $nextval = $allblogid[$index+1];
if (!empty($prevval)){$prev = $prevval;} else {$prev = current($allblogid);}
if (!empty($nextval)){$next = $nextval;} else {$next = current($allblogid);}
$getdata = $this->BeatleModel->getBlogAccId($blogid);
$newsjson = json_decode($getdata);
//echo '<pre>'; print_r($newsjson);
$preview = $newsjson[0]->blog_view;
$view = ++$preview;
$udpatearr = array('blog_view'=>$view);
$updateview = $this->db->where('id',$blogid)->update('beatle_blog',$udpatearr);
$getalltag = $this->AdminModel->getalltagactive();
// Get comment by blog id
$getblogcomment = $this->BeatleModel->getblogcomment($blogid);
$countcomment = count(json_decode($getblogcomment));
//
$getallNews = $this->AdminModel->getallNews();
$btag = json_decode($getdata);
$preblog = explode('|',$btag[0]->blog_tag);
$tagdata = $this->AdminModel->gettagAccidwherein($preblog);
// Pagination start here
// End
$data = array(
'nexvalue' => $next,
'prevalue' => $prev,
'getdata' => json_decode($getdata),
'getallNews' => json_decode($getallNews),
'getblogcomment' => json_decode($getblogcomment),
'countcomment' => $countcomment,
'getallblog' => json_decode($getallblog),
'tagdata' => $tagdata,
'getalltag' => $getalltag
);
if(!empty($_POST) && !empty($this->input->post('useremail'))){
$email = $this->input->post('useremail');
$username = $this->input->post('username');
$comment = $this->input->post('comment');
$blog_id = $this->input->post('blog_id');
$datare = $this->BeatleModel->addcomment($email,$username,$comment,$blog_id);
// echo '<pre>'; print_r($datare); die;
if (!empty($datare['message']) && $datare['status'] =='0'){
$this->session->set_flashdata("error",$datare['message']);
redirect(FRONTRND_URL.'blogDetails/'.$titleurl.'/'.base64_encode($blogid));
}else{
$this->session->set_flashdata("message",$datare['message']);
redirect(FRONTRND_URL.'blogDetails/'.$titleurl.'/'.base64_encode($blogid));
}
}
$this->load->view('beatle/blogdetails',$data);
}
public function categories()
{
//config for bootstrap pagination class integration
$catname = $this->uri->segment(3);
$config = array();
$config["base_url"] = FRONTRND_URL. "categories/".$catname;
$total_row = $this->BeatleModel->getallblogcountcat($catname);
// echo'<pre>'; print_r($total_row ); die;
$config["total_rows"] = $total_row;
$config["per_page"] = 3;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = ' <a class="page-numbers active">';
$config['cur_tag_close'] = '</a>';
$config['num_tag_open'] = ' <a class="page-numbers">';
$config['num_tag_close'] = '</a>';
$config['next_link'] = '<lable class="page-numbers next ml-sm-5 ml-3"><i class="fa fa-angle-right"></i></lable>';
$config['prev_link'] = '<lable class="page-numbers prev mr-sm-5 mr-3"><i class="fa fa-angle-left"></i></lable>';
$this->pagination->initialize($config);
// echo '<pre>'; print_r($this->pagination->initialize($config));die;
$page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
$data["links"] = $this->pagination->create_links();
$data['getallblog'] = $this->BeatleModel->getallblogcatlimit($config["per_page"], $page,$catname);
$data['getalltag'] = $this->alltag;
// echo '<pre>'; print_r($data); die;
$this->load->view('beatle/search',$data);
}
//contact us function start here
public function contact()
{
if(!empty($_POST) && !empty($_POST['conname'])){
$conname = $this->input->post('conname');
$conphone = $this->input->post('conphone');
$conemail = $this->input->post('conemail');
$comment = $this->input->post('comment');
$data = $this->BeatleModel->sendcontactmail($conname,$conphone,$conemail,$comment);
if($data == TRUE){
$this->session->set_flashdata("message","Thanks for contact us. We will contact you soon!");
}
}
$data = array('getalltag'=>$this->alltag);
$this->load->view('beatle/contactus',$data);
}
// Check user email
public function checkuser()
{
$email = $_POST['useremail'];
$data = $this->BeatleModel->checkuser($email);
if (!empty($data)){
return true;
}
else{
return false;
}
}
// Verify Email For comment
public function verifyUserComment()
{
$getcode = $this->uri->segment(3);
$getemail = $this->uri->segment(4);
$blogid = $this->uri->segment(5);
$data = $this->BeatleModel->verifyUserComment($getcode,$getemail);
if ($data == TRUE){
redirect(FRONTRND_URL.'blogDetails/'.$blogid);
}else{
redirect(FRONTRND_URL.'blogDetails/'.$blogid);
$this->session->set_flashdata('error','Enable to verify email.Please try again');
}
}
// News Like Dislike start here
public function newsLikeDislike()
{
$news_id = $_POST['news_id'];
$news_table = $_POST['news_table'];
$newslike_type = $_POST['newslike_type'];
$data = $this->BeatleModel->newsLikeDislike($news_id,$news_table,$newslike_type);
echo '<pre>'; print_r($data);
}
// End here
public function blogLikeDislike()
{
$news_id = $_POST['news_id'];
$news_table = $_POST['news_table'];
$newslike_type = $_POST['newslike_type'];
$data = $this->BeatleModel->blogLikeDislike($news_id,$news_table,$newslike_type);
echo '<pre>'; print_r($data);
}
//list details start here
public function listdetails()
{
$listid = base64_decode($this->uri->segment(3));
$getlistdata = $this->BeatleModel->getlistbyid($listid);
$getlisting = $this->BeatleModel->getallilsting();
$getlistphoto = $this->BeatleModel->getlistphoto($listid);
$getfeedback = $this->BeatleModel->gettotalfeedback($listid);
// echo '<pre>'; print_r($getlistphoto); die;
$data = array('getalltag' => $this->alltag,
'getlistdata' => json_decode($getlistdata),
'getlisting' => json_decode($getlisting),
'getlistphoto' => $getlistphoto,
'getfeedback' => $getfeedback
);
$this->load->view('beatle/listdetails',$data);
}
// end here
// page accoirding to the list type
public function listing()
{
$listtype = $this->uri->segment(3);
if ($listtype == 'comingsoon'){
$data = array('getalltag' => $this->alltag);
$this->load->view('beatle/commingsoon',$data);
}
else
{
$getlistacctype = $this->BeatleModel->getlistacctype($listtype);
$data = array(
'getalltag' => $this->alltag,
'getlistacctype' => json_decode($getlistacctype),
'listtype' => $listtype
);
//echo '<pre>'; print_r(json_decode($getlistacctype)); die;
$this->load->view('beatle/listing',$data);
}
}
}