Subversion Repositories SmartDukaan

Rev

Rev 12706 | 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();
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
	}
145
 
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
	}
160
 
161
    function signupcounter() {
162
    	$data = array();    	
163
		if (isset($_SERVER['HTTP_REFERER'])) {
164
			if ((strpos($_SERVER['HTTP_REFERER'],'login') == false) && (strpos($_SERVER['HTTP_REFERER'],'register') == false)) {
165
   				$redirect = $_SERVER['HTTP_REFERER'];
166
   				$location = $this->session->userdata('location');
167
   				$this->session->set_userdata('location',$redirect);	
168
			}
169
		}
170
 
171
		//get cache 
172
		$fosauthorized = $this->session->userdata('fosauthorized');
173
		if(isset($_POST) && !empty($_POST)) {
12700 anikendra 174
			/*if(isset($fosauthorized) && !empty($fosauthorized)) {
12694 anikendra 175
				$_POST['userId'] = $fosauthorized['Id'];
176
				if($fosauthorized['isLoggedIn'] == 1){
177
					$_POST['isLoggedIn'] = 'true';
178
				}
179
				elseif(isset($fosauthorized['isLoggedIn']) && empty($fosauthorized['isLoggedIn'])) {
180
					$_POST['isLoggedIn'] = 'false';
181
				}
12700 anikendra 182
			}*/	
12694 anikendra 183
 
184
			$configdata =array();
185
			$configdata = $this->config->item('fos_signupcounter');
186
			unset($configdata['response'][0]);
187
			$data['response']=$this->fos_model->getSignup($this->input->get(),$this->input->post(),$configdata);
188
			//set cache to output or renew cache
12700 anikendra 189
			if(isset($data['response']['response']['fossignup']['authorized']['id']))
12694 anikendra 190
			{
12700 anikendra 191
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['fossignup']['msg']));
192
				$this->session->set_userdata('username',$data['response']['response']['fossignup']['authorized']['id']);
193
				$this->session->set_userdata('countercode',$data['response']['response']['fossignup']['authorized']['counterCode']);
12706 anikendra 194
				redirect(base_url().$data['response']['response']['fossignup']['redirect']."?username=".$data['response']['response']['fossignup']['authorized']['id']."&countercode=".$data['response']['response']['fossignup']['authorized']['counterCode']);
12694 anikendra 195
			}
196
			else
197
			{
198
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
199
				$data['title'] = 'Saholic';
200
				$data['stylesheet'] = 'auth.css';
12700 anikendra 201
				$this->session->set_flashdata(array('msg'=>$data['response']['response']['messsage']));
202
				redirect(base_url().$data['response']['response']['fossignup']['redirect']);	
12694 anikendra 203
			}
204
		} else {
205
			$configdata =array();
206
			$configdata = $this->config->item('fossignup');
207
			unset($configdata['response'][1]);
208
			$cachemodule = array('header','footer','response');
209
			$configdata = getCache($configdata,$cachemodule);
210
			$data = array();
211
			$data['response']=$this->fos_model->getLogin($this->input->get(),$this->input->post(),$configdata['module']);
212
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
213
			$data['stylesheet'] = 'shipping.css';
214
			$data['title'] = 'Register Counter';
215
			if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
216
			{
217
				foreach($cachemodule as $cm)
218
				{
219
					if(isset($configdata[$cm]) and !empty($configdata[$cm]))
220
					{
221
						$data['response'][$cm]=$configdata[$cm];
222
					}
223
				}
224
			}
225
			setCache($configdata['module'],$cachemodule,$data['response']);
226
			$this->layout->view(strtolower(__CLASS__).'/signupcounter',$data);
227
		}
228
    }
229
 
230
    function thanks() {
231
    	$configdata = $this->config->item('fos_dashboard');
232
		$cachemodule = array('header','footer');
233
	    $configdata = getCache($configdata,$cachemodule);
234
	    //end of get cache
235
	    $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
236
	    $data['stylesheet'] = 'recharge.css';
12706 anikendra 237
	    $data['title'] = 'Thanks';
12732 anikendra 238
		$username = $this->session->userdata('username');
239
		if(!empty($username)){
240
		    $data['username'] = $username;
241
		}else{
242
		    $data['username'] = $_GET['username'];
243
		}
244
		$countercode = $this->session->userdata('countercode');
245
		if(!empty($countercode)){
246
		    $data['countercode'] = $countercode;
247
		}else{
248
		    $data['countercode'] = $_GET['countercode'];
249
		}
12694 anikendra 250
	    $data['response']=$this->fos_model->getDashboard($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));
251
		$this->layout->view(strtolower(__CLASS__).'/thanks',$data);
252
    }
12732 anikendra 253
 
254
    function searchcounter() {
255
    	if(isset($_POST) && !empty($_POST)) {
256
    		// $_GET = $_POST;
257
    		// unset($_POST);
258
			if(isset($fosauthorized) && !empty($fosauthorized)) {
259
				$_POST['userId'] = $fosauthorized['Id'];			
260
			}	
261
			$configdata =array();
262
			$configdata = $this->config->item('fos_searchcounter');
263
			unset($configdata['response'][0]);
264
			$data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$configdata);
265
			//set cache to output or renew cache
266
			$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
267
		    $data['stylesheet'] = 'recharge.css';
268
		    $data['title'] = 'Search Counter';
269
			$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);	
270
		}else{
271
			$configdata = $this->config->item('fos_searchcounter');
272
			$cachemodule = array('header','footer');
273
		    $configdata = getCache($configdata,$cachemodule);
274
		    //end of get cache
275
		    $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
276
		    $data['stylesheet'] = 'recharge.css';
277
		    $data['title'] = 'Search Counter';
278
		    $data['response']=$this->fos_model->getSearch($this->input->get(),$this->input->post(),$this->config->item('fos_dashboard'));
279
			$this->layout->view(strtolower(__CLASS__).'/searchuser',$data);	
280
		}
281
	}     
282
 
283
	function loginas($userid,$cartId) {
284
		$auth = array('Id'=>$userid,'isLoggedIn'=>1,'cartId'=>$cartId,'isPrivateDealUser'=>1);
285
		$this->session->set_userdata('authorized',$auth);
286
		redirect('/search');
287
	}
288
 
289
	function getusers($id) {
290
		$configdata =array();
291
		$configdata = $this->config->item('fos_getcounterusers');
292
		unset($configdata['response'][0]);
293
		$data['response']=$this->fos_model->getUser($this->input->get(),array('counter_id'=>$id),$configdata);
294
		//set cache to output or renew cache
295
		$this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
296
	    $data['stylesheet'] = 'recharge.css';
297
	    $data['title'] = 'Users list';
298
		$this->layout->view(strtolower(__CLASS__).'/listuser',$data);	
299
	}
12704 anikendra 300
}
12732 anikendra 301