Subversion Repositories SmartDukaan

Rev

Rev 12732 | Rev 12770 | 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();
12704 anikendra 59
/*
12694 anikendra 60
		 if (isset($_SERVER['HTTP_REFERER'])) {
61
			if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {
62
   				$redirect = $_SERVER['HTTP_REFERER'];   				
63
   				$location = $this->session->userdata('location');
64
   				if(isset($location) && $location == 'shipping'){
65
   					$data['location'] = 'shipping';
66
   					$location = base_url().$location;
67
   					$this->session->set_userdata('location',$location);
68
   				}elseif(isset($location) && ($location == 'my-recharges' || $location == 'my-wallet')){
69
   					$location = base_url().$location;
70
   					$this->session->set_userdata('location',$location);
71
   				}else{
72
   					$this->session->set_userdata('location',$redirect);	
73
   				}
74
 
75
			}
76
		}
12704 anikendra 77
*/
12694 anikendra 78
		$fosauthorized = $this->session->userdata('fosauthorized');
12700 anikendra 79
		if(isset($fosauthorized) && !empty($fosauthorized) && $fosauthorized['isLoggedIn'] == 1){
12694 anikendra 80
			redirect(base_url().'fos/dashboard');
81
		}
82
		//get cache 
83
		$fosauthorized = $this->session->userdata('fosauthorized');
84
		if(isset($_POST) && !empty($_POST)) {
85
			if(isset($fosauthorized) && !empty($fosauthorized)){
86
				$_POST['username'] = $fosauthorized['username'];
87
				// $_POST['cartId'] = $fosauthorized['cartId'];
88
				if($fosauthorized['isActive'] == 1){
89
					$_POST['isLoggedIn'] = 'true';
90
				}
91
				elseif(isset($fosauthorized['isActive']) && empty($fosauthorized['isActive'])) {
92
					$_POST['isLoggedIn'] = 'false';
93
				}
94
			}
95
			//end of get cache
96
			$configdata =array();
97
			$configdata = $this->config->item('fos_login');
98
			unset($configdata['response'][0]);
99
			$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata);
100
			//set cache to output or renew cache
101
			if(isset($data['response']['response']['foslogin']['fosauthorized']))
102
			{
103
				$this->session->set_userdata('fosauthorized',$data['response']['response']['foslogin']['fosauthorized']);
104
				//$this->session->set_flashdata(array('msg'=>$data['response']['response']['login']['msg']));
105
				$location = $this->session->userdata('location');
106
				if(isset($location) && !empty($location)){
107
					$this->session->unset_userdata('location');
108
					redirect($location);
109
				} else{
12704 anikendra 110
 
12694 anikendra 111
					redirect(base_url().$data['response']['response']['foslogin']['redirect']);	
112
				}
113
			} else {
114
				$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
115
				$data['title'] = 'Saholic';
116
				$data['stylesheet'] = 'auth.css';
12700 anikendra 117
				// $this->layout->view(strtolower(__CLASS__).'/fos_view',$data);
118
				redirect(base_url().'fos/login');	
12694 anikendra 119
			}
120
		} else{
121
			$configdata =array();
122
			$configdata = $this->config->item('fos_login');
123
			unset($configdata['response'][1]);
124
			$cachemodule = array('header','footer','response');
125
			$configdata = getCache($configdata,$cachemodule);
126
			$data = array();
127
			$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
128
			$this->lessphp->object()->ccompile('assets/css/auth.less','assets/css/auth.css');
129
			$data['title'] = 'Login';
130
			$data['stylesheet'] = 'auth.css';
131
			if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
132
			{
133
				foreach($cachemodule as $cm)
134
				{
135
					if(isset($configdata[$cm]) and !empty($configdata[$cm]))
136
					{
137
						$data['response'][$cm]=$configdata[$cm];
138
					}
139
				}
140
			}
141
			setCache($configdata['module'],$cachemodule,$data['response']);
142
			$this->layout->view(strtolower(__CLASS__).'/login',$data);
143
		}
144
	}
12763 anikendra 145
/*
12694 anikendra 146
	function logout() {
147
		$fosauthorized = $this->session->userdata('fosauthorized');
148
		if(isset($fosauthorized) and !empty($fosauthorized))
149
		{
150
			$this->session->unset_userdata('fosauthorized');
151
			$this->session->unset_userdata('authorized');
152
			$this->session->unset_userdata('addressId');
153
			$this->session->unset_userdata('hotspotId');
154
			$this->session->unset_userdata('cod');
155
			$this->session->unset_userdata('userId');
156
			$this->session->unset_userdata('captcha');
157
			redirect(base_url().'home');
158
		}
159
	}
12763 anikendra 160
*/
161
	function changeuser() {
162
		$authorized = $this->session->userdata('authorized');
163
		if(isset($authorized) and !empty($authorized))
164
		{
165
			$this->session->unset_userdata('authorized');
166
			$this->session->unset_userdata('addressId');
167
			$this->session->unset_userdata('hotspotId');
168
			$this->session->unset_userdata('cod');
169
			$this->session->unset_userdata('userId');
170
			$this->session->unset_userdata('captcha');
171
			redirect(base_url().'fos/searchcounter');
172
		}
173
	}
12694 anikendra 174
 
175
    function signupcounter() {
176
    	$data = array();    	
177
		if (isset($_SERVER['HTTP_REFERER'])) {
178
			if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {
179
   				$redirect = $_SERVER['HTTP_REFERER'];
180
   				$location = $this->session->userdata('location');
181
   				$this->session->set_userdata('location',$redirect);	
182
			}
183
		}
184
 
185
		//get cache 
186
		$fosauthorized = $this->session->userdata('fosauthorized');
187
		if(isset($_POST) && !empty($_POST)) {
12700 anikendra 188
			/*if(isset($fosauthorized) && !empty($fosauthorized)) {
12694 anikendra 189
				$_POST['userId'] = $fosauthorized['Id'];
190
				if($fosauthorized['isLoggedIn'] == 1){
191
					$_POST['isLoggedIn'] = 'true';
192
				}
193
				elseif(isset($fosauthorized['isLoggedIn']) && empty($fosauthorized['isLoggedIn'])) {
194
					$_POST['isLoggedIn'] = 'false';
195
				}
12700 anikendra 196
			}*/	
12694 anikendra 197
 
198
			$configdata =array();
199
			$configdata = $this->config->item('fos_signupcounter');
200
			unset($configdata['response'][0]);
201
			$data['response']=$this->fos_model->getSignup($this->input->get(),$this->input->post(),$configdata);
202
			//set cache to output or renew cache
12700 anikendra 203
			if(isset($data['response']['response']['fossignup']['authorized']['id']))
12694 anikendra 204
			{
12700 anikendra 205
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['fossignup']['msg']));
206
				$this->session->set_userdata('username',$data['response']['response']['fossignup']['authorized']['id']);
207
				$this->session->set_userdata('countercode',$data['response']['response']['fossignup']['authorized']['counterCode']);
12706 anikendra 208
				redirect(base_url().$data['response']['response']['fossignup']['redirect']."?username=".$data['response']['response']['fossignup']['authorized']['id']."&countercode=".$data['response']['response']['fossignup']['authorized']['counterCode']);
12694 anikendra 209
			}
210
			else
211
			{
212
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
213
				$data['title'] = 'Saholic';
214
				$data['stylesheet'] = 'auth.css';
12700 anikendra 215
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['messsage']));
216
				redirect(base_url().$data['response']['response']['fossignup']['redirect']);	
12694 anikendra 217
			}
218
		} else {
219
			$configdata =array();
220
			$configdata = $this->config->item('fossignup');
221
			unset($configdata['response'][1]);
222
			$cachemodule = array('header','footer','response');
223
			$configdata = getCache($configdata,$cachemodule);
224
			$data = array();
225
			$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
226
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
227
			$data['stylesheet'] = 'shipping.css';
228
			$data['title'] = 'Register Counter';
229
			if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
230
			{
231
				foreach($cachemodule as $cm)
232
				{
233
					if(isset($configdata[$cm]) and !empty($configdata[$cm]))
234
					{
235
						$data['response'][$cm]=$configdata[$cm];
236
					}
237
				}
238
			}
239
			setCache($configdata['module'],$cachemodule,$data['response']);
240
			$this->layout->view(strtolower(__CLASS__).'/signupcounter',$data);
241
		}
242
    }
243
 
244
    function thanks() {
245
    	$configdata = $this->config->item('fos_dashboard');
246
		$cachemodule = array('header','footer');
247
	    $configdata = getCache($configdata,$cachemodule);
248
	    //end of get cache
249
	    $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
250
	    $data['stylesheet'] = 'recharge.css';
12706 anikendra 251
	    $data['title'] = 'Thanks';
12732 anikendra 252
		$username = $this->session->userdata('username');
253
		if(!empty($username)){
254
		    $data['username'] = $username;
255
		}else{
256
		    $data['username'] = $_GET['username'];
257
		}
258
		$countercode = $this->session->userdata('countercode');
259
		if(!empty($countercode)){
260
		    $data['countercode'] = $countercode;
261
		}else{
262
		    $data['countercode'] = $_GET['countercode'];
263
		}
12694 anikendra 264
	    $data['response']=$this->fos_model->getDashboard($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));
265
		$this->layout->view(strtolower(__CLASS__).'/thanks',$data);
266
    }
12732 anikendra 267
 
268
    function searchcounter() {
269
    	if(isset($_POST) && !empty($_POST)) {
270
    		// $_GET = $_POST;
271
    		// unset($_POST);
272
			if(isset($fosauthorized) && !empty($fosauthorized)) {
273
				$_POST['userId'] = $fosauthorized['Id'];			
274
			}	
275
			$configdata =array();
276
			$configdata = $this->config->item('fos_searchcounter');
277
			unset($configdata['response'][0]);
278
			$data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$configdata);
279
			//set cache to output or renew cache
280
			$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
281
		    $data['stylesheet'] = 'recharge.css';
282
		    $data['title'] = 'Search Counter';
283
			$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);	
284
		}else{
285
			$configdata = $this->config->item('fos_searchcounter');
286
			$cachemodule = array('header','footer');
287
		    $configdata = getCache($configdata,$cachemodule);
288
		    //end of get cache
289
		    $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
290
		    $data['stylesheet'] = 'recharge.css';
291
		    $data['title'] = 'Search Counter';
292
		    $data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));
293
			$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);	
294
		}
295
	}     
296
 
12763 anikendra 297
	function loginas($userid,$cartId,$email) {
298
		$auth = array('Id'=>$userid,'isLoggedIn'=>1,'cartId'=>$cartId,'isPrivateDealUser'=>1,'email'=>$email);
12732 anikendra 299
		$this->session->set_userdata('authorized',$auth);
300
		redirect('/search');
301
	}
302
 
303
	function getusers($id) {
304
		$configdata =array();
305
		$configdata = $this->config->item('fos_getcounterusers');
306
		unset($configdata['response'][0]);
307
		$data['response']=$this->fos_model->getUser($this->input->get(),array('counter_id'=>$id),$configdata);
308
		//set cache to output or renew cache
309
		$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
310
	    $data['stylesheet'] = 'recharge.css';
311
	    $data['title'] = 'Users list';
312
		$this->layout->view(strtolower(__CLASS__).'/listuser',$data);	
313
	}
12704 anikendra 314
}
12732 anikendra 315