Rev 12770 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Fos extends MY_Controller {public $layoutName ='';function __construct() {// Call the CI_controller constructorparent::__construct();$this->output->set_header("HTTP/1.0 200 OK");$this->output->set_header("HTTP/1.1 200 OK");$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");$this->output->set_header("Cache-Control: post-check=0, pre-check=0");$this->output->set_header("Pragma: no-cache");$this->layout->setlayout('layout/layout_main');$this->load->model('fos_model');$this->layoutName= $this->layout->getLayout();$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';}public function index(){$this->__oauthorization();}function __oauthorization(){//sample session storage.. later i will imporve security for login$check =$this->session->userdata('fosauthorize');// print_r($check);die;if(isset($check) and !empty($check) and $check['authority']='success'){redirect(base_url().'fos/dashboard');}else{$this->login();}}function dashboard() {$configdata = $this->config->item('fos_dashboard');$cachemodule = array('header','footer');$configdata = getCache($configdata,$cachemodule);//end of get cache$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');$data['stylesheet'] = 'recharge.css';$data['title'] = 'Dashboard';$data['response']=$this->fos_model->getDashboard($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));$this->layout->view(strtolower(__CLASS__).'/dashboard',$data);}function login(){//standard array$data = array();$fosauthorized = $this->session->userdata('fosauthorized');if(isset($fosauthorized) && !empty($fosauthorized) && $fosauthorized['isLoggedIn'] == 1){redirect(base_url().'fos/dashboard');}//get cache$fosauthorized = $this->session->userdata('fosauthorized');if(isset($_POST) && !empty($_POST)) {if(isset($fosauthorized) && !empty($fosauthorized)){$_POST['username'] = $fosauthorized['username'];// $_POST['cartId'] = $fosauthorized['cartId'];if($fosauthorized['isActive'] == 1){$_POST['isLoggedIn'] = 'true';}elseif(isset($fosauthorized['isActive']) && empty($fosauthorized['isActive'])) {$_POST['isLoggedIn'] = 'false';}}//end of get cache$configdata =array();$configdata = $this->config->item('fos_login');unset($configdata['response'][0]);$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata);//set cache to output or renew cacheif(isset($data['response']['response']['foslogin']['fosauthorized'])){$this->session->set_userdata('fosauthorized',$data['response']['response']['foslogin']['fosauthorized']);//$this->session->set_flashdata(array('msg'=>$data['response']['response']['login']['msg']));$location = $this->session->userdata('location');if(isset($location) && !empty($location)){$this->session->unset_userdata('location');redirect($location);} else{redirect(base_url().$data['response']['response']['foslogin']['redirect']);}} else {$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');$data['title'] = 'Saholic';$data['stylesheet'] = 'auth.css';// $this->layout->view(strtolower(__CLASS__).'/fos_view',$data);redirect(base_url().'fos/login');}} else{$configdata =array();$configdata = $this->config->item('fos_login');unset($configdata['response'][1]);$cachemodule = array('header','footer','response');$configdata = getCache($configdata,$cachemodule);$data = array();$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');$data['title'] = 'Login';$data['stylesheet'] = 'auth.css';if(isset($cachemodule) and !empty($cachemodule) && !isset($api)){foreach($cachemodule as $cm){if(isset($configdata[$cm]) and !empty($configdata[$cm])){$data['response'][$cm]=$configdata[$cm];}}}setCache($configdata['module'],$cachemodule,$data['response']);$this->layout->view(strtolower(__CLASS__).'/login',$data);}}function changeuser() {$authorized = $this->session->userdata('authorized');if(isset($authorized) and !empty($authorized)){$this->session->unset_userdata('authorized');$this->session->unset_userdata('addressId');$this->session->unset_userdata('hotspotId');$this->session->unset_userdata('cod');$this->session->unset_userdata('userId');$this->session->unset_userdata('captcha');redirect(base_url().'fos/searchcounter');}}function signupcounter() {$data = array();if (isset($_SERVER['HTTP_REFERER'])) {if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {$redirect = $_SERVER['HTTP_REFERER'];$location = $this->session->userdata('location');$this->session->set_userdata('location',$redirect);}}//get cache$fosauthorized = $this->session->userdata('fosauthorized');if(isset($_POST) && !empty($_POST)) {if(!isset($_POST['tinskipped'])){$_POST['tinskipped'] = 0;}else{$_POST['tin'] = null;}$configdata =array();$configdata = $this->config->item('fos_signupcounter');unset($configdata['response'][0]);$data['response']=$this->fos_model->getSignup($this->input->get(),$this->input->post(),$configdata);//set cache to output or renew cacheif(isset($data['response']['response']['fossignup']['authorized']['id'])){$this->session->set_flashdata(array('msg'=>$data['response']['response']['fossignup']['msg']));$this->session->set_userdata('username',$data['response']['response']['fossignup']['authorized']['id']);$this->session->set_userdata('countercode',$data['response']['response']['fossignup']['authorized']['counterCode']);redirect(base_url().$data['response']['response']['fossignup']['redirect']."?username=".$data['response']['response']['fossignup']['authorized']['id']."&countercode=".$data['response']['response']['fossignup']['authorized']['counterCode']);}else{$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');$data['title'] = 'Saholic';$data['stylesheet'] = 'auth.css';$this->session->set_flashdata(array('msg'=>$data['response']['response']['fossignup']['msg']));redirect(base_url().$data['response']['response']['fossignup']['redirect']);}} else {$configdata =array();$configdata = $this->config->item('fossignup');unset($configdata['response'][1]);$cachemodule = array('header','footer','response');$configdata = getCache($configdata,$cachemodule);$data = array();$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');$data['stylesheet'] = 'shipping.css';$data['title'] = 'Register Counter';if(isset($cachemodule) and !empty($cachemodule) && !isset($api)){foreach($cachemodule as $cm){if(isset($configdata[$cm]) and !empty($configdata[$cm])){$data['response'][$cm]=$configdata[$cm];}}}$data['response']['msg'] = $this->session->flashdata('msg');setCache($configdata['module'],$cachemodule,$data['response']);$this->layout->view(strtolower(__CLASS__).'/signupcounter',$data);}}function confirmcounter() {if(isset($_POST) && !empty($_POST)) {$data = array('formdata'=>$_POST);$data['stylesheet'] = 'shipping.css';$this->layout->view(strtolower(__CLASS__).'/confirmcounter',$data);}}function thanks() {$configdata = $this->config->item('fos_dashboard');$cachemodule = array('header','footer');$configdata = getCache($configdata,$cachemodule);//end of get cache$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');$data['stylesheet'] = 'recharge.css';$data['title'] = 'Thanks';$username = $this->session->userdata('username');if(!empty($username)){$data['username'] = $username;}else{$data['username'] = $_GET['username'];}$countercode = $this->session->userdata('countercode');if(!empty($countercode)){$data['countercode'] = $countercode;}else{$data['countercode'] = $_GET['countercode'];}$data['response']=$this->fos_model->getDashboard($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));$this->layout->view(strtolower(__CLASS__).'/thanks',$data);}function searchcounter() {if(isset($_POST) && !empty($_POST)) {// $_GET = $_POST;// unset($_POST);if(isset($fosauthorized) && !empty($fosauthorized)) {$_POST['userId'] = $fosauthorized['Id'];}$configdata =array();$configdata = $this->config->item('fos_searchcounter');unset($configdata['response'][0]);$data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$configdata);//set cache to output or renew cache$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');$data['stylesheet'] = 'recharge.css';$data['title'] = 'Search Counter';$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);}else{$configdata = $this->config->item('fos_searchcounter');$cachemodule = array('header','footer');$configdata = getCache($configdata,$cachemodule);//end of get cache$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');$data['stylesheet'] = 'recharge.css';$data['title'] = 'Search Counter';$data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);}}function loginas($userid,$cartId,$email) {$auth = array('Id'=>$userid,'isLoggedIn'=>1,'cartId'=>$cartId,'isPrivateDealUser'=>1,'email'=>$email);$this->session->set_userdata('authorized',$auth);redirect('/search');}function getusers($id) {$configdata =array();$configdata = $this->config->item('fos_getcounterusers');unset($configdata['response'][0]);$data['response']=$this->fos_model->getUser($this->input->get(),array('counter_id'=>$id),$configdata);//set cache to output or renew cache$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');$data['stylesheet'] = 'recharge.css';$data['title'] = 'Users list';$this->layout->view(strtolower(__CLASS__).'/listuser',$data);}}