Subversion Repositories SmartDukaan

Rev

Rev 18142 | Rev 18192 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18142 Rev 18148
Line 17... Line 17...
17
 
17
 
18
		public function index() {
18
		public function index() {
19
		$encryptUrl = 'http://shop2020.in:8057/message/encrypt?type=encrypt&data=';
19
		$encryptUrl = 'http://shop2020.in:8057/message/encrypt?type=encrypt&data=';
20
		$expiryFlag=false;
20
		$expiryFlag=false;
21
		$redirectFlag=false;
21
		$redirectFlag=false;
22
		$this->layout = 'empty';
22
		$this->layout = 'ajax';
23
		$serverHost= $_SERVER['HTTP_HOST'];
23
		$serverHost= $_SERVER['HTTP_HOST'];
24
		$serverURI = $_SERVER['REQUEST_URI'];
24
		$serverURI = $_SERVER['REQUEST_URI'];
25
		$requestURL ="http://".$serverHost.$serverURI;
25
		$requestURL ="http://".$serverHost.$serverURI;
26
		$intentToSend = '';
26
		$intentToSend = '';
27
		$params = explode($serverHost.'/a', $requestURL);
27
		$params = explode($serverHost.'/a', $requestURL);
Line 74... Line 74...
74
					    		$notificationUrl = $row['url'];
74
					    		$notificationUrl = $row['url'];
75
					    		$notificationType = $row['type'];
75
					    		$notificationType = $row['type'];
76
					    		$notificationExpires = $row['expiresat'];
76
					    		$notificationExpires = $row['expiresat'];
77
					    		$notificationStatus = $row['status'];
77
					    		$notificationStatus = $row['status'];
78
					    		$currentTime = time();
78
					    		$currentTime = time();
-
 
79
					    		if(!strtotime($notificationExpires)){
-
 
80
					    			$notificationExpires='2038-01-19 03:14:07';
-
 
81
					    		}
-
 
82
					    		//debug($currentTime);
-
 
83
					    		//debug($notificationExpires);
79
					    		if(strtotime($notificationExpires) < $currentTime || $notificationStatus=='inactive'){
84
					    		if(strtotime($notificationExpires) < $currentTime || $notificationStatus=='inactive'){
80
					    			//debug('Notification has expired');
85
					    			//debug('Notification has expired');
81
					    			$expiryFlag=true;
86
					    			$expiryFlag=true;
82
					    		}
87
					    		}
83
								if($notificationType=='native'){
88
								if($notificationType=='native'){
Line 110... Line 115...
110
							}
115
							}
111
					    }
116
					    }
112
					}else{
117
					}else{
113
						$encryptedData = $this->defaultEncryptedMessage($userId);
118
						$encryptedData = $this->defaultEncryptedMessage($userId);
114
					}		
119
					}		
115
					//debug($encryptedData);
-
 
116
					//debug($this->decrypt(urlencode($encryptedData['result']['value'])));
-
 
117
				}	
120
				}	
118
			}
121
			}
119
		}
122
		}
120
		if($redirectFlag){
123
		if($redirectFlag){
121
			debug('The user needs to be redirected');
-
 
122
			echo('The user needs to be redirected');
124
			$this->redirect(array('action'=>'error'));
123
		}else{
125
		}else{
124
			$intentToSend = 'intent://pmapp.com?key='.urlencode($encryptedData['result']['value']).'&campaign='.$campaignId.'&intent_type='.$notificationType.'#Intent;scheme=profitmandiapp;package=com.saholic.profittill;end';							
-
 
125
			//if()
-
 
126
			$this->set(compact('intentToSend','expiryFlag'));
-
 
127
			header('Location: '.$intentToSend);
-
 
128
			exit;	
-
 
129
			//debug($intentToSend);
-
 
130
			//debug($expiryFlag);
126
			//debug($expiryFlag);
-
 
127
			$intentToSend = 'intent://pmapp.com?key='.urlencode($encryptedData['result']['value']).'&campaign='.$campaignId.'&intent_type='.$notificationType.'#Intent;scheme=profitmandiapp;package=com.saholic.profittill;end';							
-
 
128
			if($expiryFlag){
-
 
129
				$this->set(compact('intentToSend','expiryFlag'));
-
 
130
			}else{
-
 
131
				header('Location: '.$intentToSend);
-
 
132
				exit;	
-
 
133
			}
131
		}
134
		}
132
	}
135
	}
133
 
136
 
134
	function defaultEncryptedMessage($userId){
137
	function defaultEncryptedMessage($userId){
135
		$encryptUrl = 'http://shop2020.in:8057/message/encrypt?type=encrypt&data=';
138
		$encryptUrl = 'http://shop2020.in:8057/message/encrypt?type=encrypt&data=';
136
		$defaultEncryptedData =array();
139
		$defaultEncryptedData =array();
137
		$defaultUrl = 'http://api.profittill.com/deals';
140
		$defaultUrl = 'http://api.profittill.com/deals';
138
		// if(empty($userId)){
-
 
139
		// 	$notificationUrl = $defaultUrl;
-
 
140
		// }else{
-
 
141
		// 	$notificationUrl = $defaultUrl.'?user_id='.$userId;
-
 
142
		// }
-
 
143
		$notificationUrl = $defaultUrl.'?user_id='.$userId;
141
		$notificationUrl = $defaultUrl.'?user_id='.$userId;
144
	    $encryptUrl = $encryptUrl.base64_encode($notificationUrl);
142
	    $encryptUrl = $encryptUrl.base64_encode($notificationUrl);
145
	    $defaultEncryptedData = $this->make_request($encryptUrl,null);
143
	    $defaultEncryptedData = $this->make_request($encryptUrl,null);
146
	    return $defaultEncryptedData;
144
	    return $defaultEncryptedData;
147
	}
145
	}
Line 186... Line 184...
186
			}else{
184
			}else{
187
				return $conn;		
185
				return $conn;		
188
			}
186
			}
189
		}
187
		}
190
	}
188
	}
-
 
189
	function error(){
-
 
190
			$this->layout='ajax';
-
 
191
			$name='Sorry';
-
 
192
			$this->set(compact('name'));
-
 
193
	}
191
}
194
}