<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Home extends MY_Controller
{
public function __construct()
{
parent::__construct();
$this->load->driver('cache', array('adapter' => 'file'));
$this->load->model(['Home_model', 'Home_admin_model','admin/Banner_model']);
$this->load->helper('webp'); // Load your WebP conversion helper
}
public function error_404()
{
redirect(base_url(), 'refresh');
}
public function index()
{
// $this->output->cache(60); // Cache for 1 minute
$head = $this->getHeaderData();
$data = [];
$data['client_logo'] = $this->getClientLogos();
$data['client_master_count'] = $this->Home_model->clientMasterCount();
$currentDate = date('Y-m-d');
$banner = $this->Banner_model->get_active_banner($currentDate);
$data['showPopup'] = !empty($banner);
$data['banner'] = $banner;
$this->load->view('parts/header', $head);
$this->load->view('home/home', $data);
$this->load->view('parts/footer');
}
public function logo()
{
$head = $this->getHeaderData();
$data = [];
$data['client_logo'] = $this->getClientLogos();
$data['client_master_count'] = $this->Home_model->clientMasterCount();
$this->checkRedirect('http://cm.bidmasters.in/costmasters/index.php');
$this->load->view('parts/header', $head);
$this->load->view('home/logo', $data);
$this->load->view('parts/footer');
}
private function getHeaderData()
{
return [
'title' => 'Commodity Prices-Latest & Future,Zero Base Costing Software - CostMasters',
'description' => 'Track prices of commodities & metals like Steel, Aluminum,Copper,Ferro Alloys,Alloy Steel,Lead,Nickel,Plastic,Rubber,Fuel & Energy,Costing Estimation Software',
'keywords' => 'Steel prices India, Steel Prices in India, steel price index India, Stainless Steel Price in India, current steel prices in India, Steel Price Forecasting, steel prices in India trend, steel prices chart in India, raw material price, Scrap Price in India, raw material prices, cost master, Raw material prices in India, steel material price, Plastic Price in India',
'sitelogo' => $this->Home_admin_model->getValueStore('sitelogo'),
'contactsEmailTo' => $this->Home_admin_model->getValueStore('contactsEmailTo'),
'footerContactEmail' => $this->Home_admin_model->getValueStore('footerContactEmail'),
'footerContactPhone' => $this->Home_admin_model->getValueStore('footerContactPhone'),
'footerCopyright' => htmlentities($this->Home_admin_model->getValueStore('footercopyright')),
'contactsPage' => $this->Home_admin_model->getValueStore('contactspage'),
'footerSocialFacebook' => $this->Home_admin_model->getValueStore('footerSocialFacebook'),
'footerSocialTwitter' => $this->Home_admin_model->getValueStore('footerSocialTwitter'),
'footerSocialInstagram' => $this->Home_admin_model->getValueStore('footerSocialInstagram'),
'footerSocialPinterest' => $this->Home_admin_model->getValueStore('footerSocialPinterest'),
'footerSocialYoutube' => $this->Home_admin_model->getValueStore('footerSocialYoutube'),
'footerContactAddr' => $this->Home_admin_model->getValueStore('footerContactAddr'),
'googleMaps' => $this->Home_admin_model->getValueStore('googleMaps'),
];
}
private function getClientLogos()
{
$logos = $this->Home_model->getLogos();
if (is_array($logos)) {
foreach ($logos as &$logo) {
$originalPath = 'uploads/client_logo/' . $logo['upload_logo'];
$logo['upload_logo'] = $this->convertToWebp($originalPath);
}
} else {
$logos = [];
}
return $logos;
}
private function convertToWebp($originalPath)
{
if (file_exists($originalPath) && pathinfo($originalPath, PATHINFO_EXTENSION) !== 'webp') {
$webpPath = 'uploads/client_logo/' . pathinfo($originalPath, PATHINFO_FILENAME) . '.webp';
if (convert_to_webp($originalPath, $webpPath)) {
return pathinfo($webpPath, PATHINFO_BASENAME);
}
}
return pathinfo($originalPath, PATHINFO_BASENAME);
}
private function checkRedirect($url)
{
$currentUrl = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if ($currentUrl === $url) {
redirect(base_url(), 'refresh');
}
}
public function adminer()
{
$data = array();
$head = array();
$head['title'] = 'Commodity Prices-Latest & Future,Zero Base Costing Software - CostMasters';
$head['description'] = 'Track prices of commodities & metals like Steel, Aluminum,Copper,Ferro Alloys,Alloy Steel,Lead,Nickel,Plastic,Rubber,Fuel & Energy,Costing Estimation Software';
$head['keywords'] = 'Steel prices India, Steel Prices in India, steel price index India, Stainless Steel Price in India, current steel prices in India, Steel Price Forecasting, steel prices in India trend, steel prices chart in India, raw material price, Scrap Price in India, raw material prices, cost master, Raw material prices in India, steel material price, Plastic Price in India';
$head['sitelogo'] = $this->Home_admin_model->getValueStore('sitelogo');
$head['contactsEmailTo'] = $this->Home_admin_model->getValueStore('contactsEmailTo');
$head['footerContactEmail'] = $this->Home_admin_model->getValueStore('footerContactEmail');
$head['footerContactPhone'] = $this->Home_admin_model->getValueStore('footerContactPhone');
$head['footerCopyright'] = htmlentities($this->Home_admin_model->getValueStore('footercopyright'));
$head['contactsPage'] = $this->Home_admin_model->getValueStore('contactspage');
$head['footerSocialFacebook'] = $this->Home_admin_model->getValueStore('footerSocialFacebook');
$head['footerSocialTwitter'] = $this->Home_admin_model->getValueStore('footerSocialTwitter');
$head['footerSocialInstagram'] = $this->Home_admin_model->getValueStore('footerSocialInstagram');
$head['footerSocialPinterest'] = $this->Home_admin_model->getValueStore('footerSocialPinterest');
$head['footerSocialYoutube'] = $this->Home_admin_model->getValueStore('footerSocialYoutube');
$head['footerContactAddr'] = $this->Home_admin_model->getValueStore('footerContactAddr');
$head['googleMaps'] = $this->Home_admin_model->getValueStore('googleMaps');
$this->load->view('adminer',$data);
}
}
|