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