Subversion Repositories SmartDukaan

Rev

Rev 12763 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
12694 anikendra 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
 
3
class Fos extends MY_Controller {
4
 
5
public $layoutName ='';
6
 
7
	function __construct() {
8
 
9
		// Call the CI_controller constructor
12732 anikendra 10
		parent::__construct();		
12694 anikendra 11
		$this->output->set_header("HTTP/1.0 200 OK");
12
		$this->output->set_header("HTTP/1.1 200 OK");
13
		$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');
14
		$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
15
		$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
16
		$this->output->set_header("Pragma: no-cache");
17
		$this->layout->setlayout('layout/layout_main');
18
		$this->load->model('fos_model');
19
		$this->layoutName= $this->layout->getLayout();
20
		$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
21
	}
22
 
23
	public function index()
24
	{
25
		$this->__oauthorization();	
26
	}
27
 
28
	function __oauthorization()
29
	{
30
		//sample session storage.. later i will imporve security for login 
31
		$check =$this->session->userdata('fosauthorize');
32
		// print_r($check);die;
12700 anikendra 33
		if(isset($check) and !empty($check) and $check['authority']='success')
12694 anikendra 34
		{
12706 anikendra 35
			redirect(base_url().'fos/dashboard');
12694 anikendra 36
		}
37
		else
38
		{
39
			$this->login();
40
		}	
41
	}
42
 
43
	function dashboard() {
44
		$configdata = $this->config->item('fos_dashboard');
45
		$cachemodule = array('header','footer');
46
	    $configdata = getCache($configdata,$cachemodule);
47
	    //end of get cache
48
	    $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
49
	    $data['stylesheet'] = 'recharge.css';
50
	    $data['title'] = 'Dashboard';
51
	    $data['response']=$this->fos_model->getDashboard($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));
52
		$this->layout->view(strtolower(__CLASS__).'/dashboard',$data);
53
	}
54
 
55
	function login()
56
	{
57
		//standard array
58
		$data = array();
12770 anikendra 59
 
12694 anikendra 60
		$fosauthorized = $this->session->userdata('fosauthorized');
12700 anikendra 61
		if(isset($fosauthorized) && !empty($fosauthorized) && $fosauthorized['isLoggedIn'] == 1){
12694 anikendra 62
			redirect(base_url().'fos/dashboard');
63
		}
64
		//get cache 
65
		$fosauthorized = $this->session->userdata('fosauthorized');
66
		if(isset($_POST) && !empty($_POST)) {
67
			if(isset($fosauthorized) && !empty($fosauthorized)){
68
				$_POST['username'] = $fosauthorized['username'];
69
				// $_POST['cartId'] = $fosauthorized['cartId'];
70
				if($fosauthorized['isActive'] == 1){
71
					$_POST['isLoggedIn'] = 'true';
72
				}
73
				elseif(isset($fosauthorized['isActive']) && empty($fosauthorized['isActive'])) {
74
					$_POST['isLoggedIn'] = 'false';
75
				}
76
			}
77
			//end of get cache
78
			$configdata =array();
79
			$configdata = $this->config->item('fos_login');
80
			unset($configdata['response'][0]);
81
			$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata);
82
			//set cache to output or renew cache
83
			if(isset($data['response']['response']['foslogin']['fosauthorized']))
84
			{
85
				$this->session->set_userdata('fosauthorized',$data['response']['response']['foslogin']['fosauthorized']);
86
				//$this->session->set_flashdata(array('msg'=>$data['response']['response']['login']['msg']));
87
				$location = $this->session->userdata('location');
88
				if(isset($location) && !empty($location)){
89
					$this->session->unset_userdata('location');
90
					redirect($location);
91
				} else{
12704 anikendra 92
 
12694 anikendra 93
					redirect(base_url().$data['response']['response']['foslogin']['redirect']);	
94
				}
95
			} else {
96
				$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
97
				$data['title'] = 'Saholic';
98
				$data['stylesheet'] = 'auth.css';
12700 anikendra 99
				// $this->layout->view(strtolower(__CLASS__).'/fos_view',$data);
100
				redirect(base_url().'fos/login');	
12694 anikendra 101
			}
102
		} else{
103
			$configdata =array();
104
			$configdata = $this->config->item('fos_login');
105
			unset($configdata['response'][1]);
106
			$cachemodule = array('header','footer','response');
107
			$configdata = getCache($configdata,$cachemodule);
108
			$data = array();
109
			$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
110
			$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
111
			$data['title'] = 'Login';
112
			$data['stylesheet'] = 'auth.css';
113
			if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
114
			{
115
				foreach($cachemodule as $cm)
116
				{
117
					if(isset($configdata[$cm]) and !empty($configdata[$cm]))
118
					{
119
						$data['response'][$cm]=$configdata[$cm];
120
					}
121
				}
122
			}
123
			setCache($configdata['module'],$cachemodule,$data['response']);
124
			$this->layout->view(strtolower(__CLASS__).'/login',$data);
125
		}
126
	}
12770 anikendra 127
 
12763 anikendra 128
	function changeuser() {
129
		$authorized = $this->session->userdata('authorized');
130
		if(isset($authorized) and !empty($authorized))
131
		{
132
			$this->session->unset_userdata('authorized');
133
			$this->session->unset_userdata('addressId');
134
			$this->session->unset_userdata('hotspotId');
135
			$this->session->unset_userdata('cod');
136
			$this->session->unset_userdata('userId');
137
			$this->session->unset_userdata('captcha');
138
			redirect(base_url().'fos/searchcounter');
139
		}
140
	}
12694 anikendra 141
 
142
    function signupcounter() {
143
    	$data = array();    	
144
		if (isset($_SERVER['HTTP_REFERER'])) {
145
			if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {
146
   				$redirect = $_SERVER['HTTP_REFERER'];
147
   				$location = $this->session->userdata('location');
148
   				$this->session->set_userdata('location',$redirect);	
149
			}
150
		}
151
 
152
		//get cache 
153
		$fosauthorized = $this->session->userdata('fosauthorized');
154
		if(isset($_POST) && !empty($_POST)) {
155
			$configdata =array();
156
			$configdata = $this->config->item('fos_signupcounter');
157
			unset($configdata['response'][0]);
158
			$data['response']=$this->fos_model->getSignup($this->input->get(),$this->input->post(),$configdata);
159
			//set cache to output or renew cache
12700 anikendra 160
			if(isset($data['response']['response']['fossignup']['authorized']['id']))
12694 anikendra 161
			{
12700 anikendra 162
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['fossignup']['msg']));
163
				$this->session->set_userdata('username',$data['response']['response']['fossignup']['authorized']['id']);
164
				$this->session->set_userdata('countercode',$data['response']['response']['fossignup']['authorized']['counterCode']);
12706 anikendra 165
				redirect(base_url().$data['response']['response']['fossignup']['redirect']."?username=".$data['response']['response']['fossignup']['authorized']['id']."&countercode=".$data['response']['response']['fossignup']['authorized']['counterCode']);
12694 anikendra 166
			}
167
			else
168
			{
169
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
170
				$data['title'] = 'Saholic';
171
				$data['stylesheet'] = 'auth.css';
12770 anikendra 172
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['fossignup']['msg']));
12700 anikendra 173
				redirect(base_url().$data['response']['response']['fossignup']['redirect']);	
12694 anikendra 174
			}
175
		} else {
176
			$configdata =array();
177
			$configdata = $this->config->item('fossignup');
178
			unset($configdata['response'][1]);
179
			$cachemodule = array('header','footer','response');
180
			$configdata = getCache($configdata,$cachemodule);
181
			$data = array();
182
			$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
183
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
184
			$data['stylesheet'] = 'shipping.css';
185
			$data['title'] = 'Register Counter';
186
			if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
187
			{
188
				foreach($cachemodule as $cm)
189
				{
190
					if(isset($configdata[$cm]) and !empty($configdata[$cm]))
191
					{
192
						$data['response'][$cm]=$configdata[$cm];
193
					}
194
				}
195
			}
12770 anikendra 196
			$data['response']['msg'] = $this->session->flashdata('msg');
12694 anikendra 197
			setCache($configdata['module'],$cachemodule,$data['response']);
198
			$this->layout->view(strtolower(__CLASS__).'/signupcounter',$data);
199
		}
200
    }
201
 
202
    function thanks() {
203
    	$configdata = $this->config->item('fos_dashboard');
204
		$cachemodule = array('header','footer');
205
	    $configdata = getCache($configdata,$cachemodule);
206
	    //end of get cache
207
	    $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
208
	    $data['stylesheet'] = 'recharge.css';
12706 anikendra 209
	    $data['title'] = 'Thanks';
12732 anikendra 210
		$username = $this->session->userdata('username');
211
		if(!empty($username)){
212
		    $data['username'] = $username;
213
		}else{
214
		    $data['username'] = $_GET['username'];
215
		}
216
		$countercode = $this->session->userdata('countercode');
217
		if(!empty($countercode)){
218
		    $data['countercode'] = $countercode;
219
		}else{
220
		    $data['countercode'] = $_GET['countercode'];
221
		}
12694 anikendra 222
	    $data['response']=$this->fos_model->getDashboard($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));
223
		$this->layout->view(strtolower(__CLASS__).'/thanks',$data);
224
    }
12732 anikendra 225
 
226
    function searchcounter() {
227
    	if(isset($_POST) && !empty($_POST)) {
228
    		// $_GET = $_POST;
229
    		// unset($_POST);
230
			if(isset($fosauthorized) && !empty($fosauthorized)) {
231
				$_POST['userId'] = $fosauthorized['Id'];			
232
			}	
233
			$configdata =array();
234
			$configdata = $this->config->item('fos_searchcounter');
235
			unset($configdata['response'][0]);
236
			$data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$configdata);
237
			//set cache to output or renew cache
238
			$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
239
		    $data['stylesheet'] = 'recharge.css';
240
		    $data['title'] = 'Search Counter';
241
			$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);	
242
		}else{
243
			$configdata = $this->config->item('fos_searchcounter');
244
			$cachemodule = array('header','footer');
245
		    $configdata = getCache($configdata,$cachemodule);
246
		    //end of get cache
247
		    $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
248
		    $data['stylesheet'] = 'recharge.css';
249
		    $data['title'] = 'Search Counter';
250
		    $data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));
251
			$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);	
252
		}
253
	}     
254
 
12763 anikendra 255
	function loginas($userid,$cartId,$email) {
256
		$auth = array('Id'=>$userid,'isLoggedIn'=>1,'cartId'=>$cartId,'isPrivateDealUser'=>1,'email'=>$email);
12732 anikendra 257
		$this->session->set_userdata('authorized',$auth);
258
		redirect('/search');
259
	}
260
 
261
	function getusers($id) {
262
		$configdata =array();
263
		$configdata = $this->config->item('fos_getcounterusers');
264
		unset($configdata['response'][0]);
265
		$data['response']=$this->fos_model->getUser($this->input->get(),array('counter_id'=>$id),$configdata);
266
		//set cache to output or renew cache
267
		$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
268
	    $data['stylesheet'] = 'recharge.css';
269
	    $data['title'] = 'Users list';
270
		$this->layout->view(strtolower(__CLASS__).'/listuser',$data);	
271
	}
12704 anikendra 272
}
12732 anikendra 273