| Line 44... |
Line 44... |
| 44 |
$redirectFlag=true;
|
44 |
$redirectFlag=true;
|
| 45 |
}else if(sizeof($fetchParams)>4){
|
45 |
}else if(sizeof($fetchParams)>4){
|
| 46 |
$redirectFlag=true;
|
46 |
$redirectFlag=true;
|
| 47 |
}else{
|
47 |
}else{
|
| 48 |
$campaignId = $fetchParams[1];
|
48 |
$campaignId = $fetchParams[1];
|
| 49 |
$userId = $fetchParams[2];;
|
49 |
$userId = $fetchParams[2];;
|
| 50 |
|
- |
|
| 51 |
$campaignId = $this->num_decode($campaignId);
|
50 |
$campaignId = $this->num_decode($campaignId);
|
| 52 |
$userId = $this->num_decode($userId);
|
51 |
$userId = $this->num_decode($userId);
|
| 53 |
$notificationUrl='';
|
52 |
$notificationUrl='';
|
| 54 |
$encryptedData=array();
|
53 |
$encryptedData=array();
|
| 55 |
$conn=$this->getDatabaseConnection();
|
- |
|
| 56 |
if($conn){
|
- |
|
| 57 |
$sql = 'SELECT * FROM notification_campaigns WHERE id ='.$campaignId;
|
54 |
$url = Configure::read('nodeurl')."/getNotificationCampaignById?id=".$campaignId;
|
| 58 |
$result = mysql_query($sql, $conn);
|
55 |
$notificationData = $this->make_request($url,null);
|
| 59 |
if (mysql_num_rows($result)==0) {
|
56 |
/*debug($notificationData);*/
|
| 60 |
$redirectFlag=true;
|
57 |
if($notificationData!=null){
|
| 61 |
}else{
|
- |
|
| 62 |
while ($row = mysql_fetch_assoc($result)) {
|
58 |
if(!empty($notificationData)){
|
| 63 |
$notificationUrl = $row['url'];
|
59 |
$notificationUrl = $notificationData['url'];
|
| 64 |
$notificationType = $row['type'];
|
60 |
$notificationType = $notificationData['type'];
|
| 65 |
$notificationExpires = $row['expiresat'];
|
61 |
$notificationExpires = $notificationData['expiresat'];
|
| 66 |
$notificationStatus = $row['status'];
|
62 |
$notificationStatus = $notificationData['status'];
|
| 67 |
$currentTime = time();
|
63 |
$currentTime = time();
|
| 68 |
if(!strtotime($notificationExpires)){
|
- |
|
| 69 |
$notificationExpires='2038-01-19 03:14:07';
|
- |
|
| 70 |
}
|
- |
|
| 71 |
if(strtotime($notificationExpires) < $currentTime || $notificationStatus=='inactive'){
|
64 |
if($notificationExpires < ($currentTime*1000) || $notificationStatus=='inactive'){
|
| 72 |
$expiryFlag=true;
|
65 |
$expiryFlag=true;
|
| 73 |
}
|
66 |
}
|
| 74 |
if($notificationType=='native'){
|
67 |
if($notificationType=='native'){
|
| 75 |
if(strtolower($notificationUrl)=='contact' || strtolower($notificationUrl)=='profile' ||strtolower($notificationUrl)=='tutorial'){
|
68 |
if(strtolower($notificationUrl)=='contact' || strtolower($notificationUrl)=='profile' ||strtolower($notificationUrl)=='tutorial'){
|
| 76 |
$encryptUrl = $encryptUrl.base64_encode(strtolower($notificationUrl));
|
69 |
$encryptUrl = $encryptUrl.base64_encode(strtolower($notificationUrl));
|
| 77 |
$encryptedData = $this->make_request($encryptUrl,null);
|
- |
|
| 78 |
}else{
|
- |
|
| 79 |
$encryptedData = $this->defaultEncryptedMessage($userId);
|
- |
|
| 80 |
}
|
- |
|
| 81 |
}else if ($notificationType=='update'){
|
- |
|
| 82 |
$encryptUrl = $encryptUrl.base64_encode('https://play.google.com/store/apps/details?id=com.saholic.profittill');
|
- |
|
| 83 |
$encryptedData = $this->make_request($encryptUrl,null);
|
70 |
$encryptedData = $this->make_request($encryptUrl,null);
|
| 84 |
}else{
|
71 |
}else{
|
| - |
|
72 |
$encryptedData = $this->defaultEncryptedMessage($userId);
|
| - |
|
73 |
}
|
| - |
|
74 |
}else if ($notificationType=='update'){
|
| - |
|
75 |
$encryptUrl = $encryptUrl.base64_encode('https://play.google.com/store/apps/details?id=com.saholic.profittill');
|
| - |
|
76 |
$encryptedData = $this->make_request($encryptUrl,null);
|
| - |
|
77 |
}else{
|
| 85 |
if(empty($notificationUrl)){
|
78 |
if(empty($notificationUrl)){
|
| 86 |
$encryptedData = $this->defaultEncryptedMessage($userId);
|
79 |
$encryptedData = $this->defaultEncryptedMessage($userId);
|
| 87 |
}else if(strpos($notificationUrl,'?user_id=') !== false){
|
80 |
}else if(strpos($notificationUrl,'?user_id=') !== false){
|
| 88 |
$encryptUrl = $encryptUrl.base64_encode($notificationUrl);
|
81 |
$encryptUrl = $encryptUrl.base64_encode($notificationUrl);
|
| 89 |
$encryptedData = $this->make_request($encryptUrl,null);
|
82 |
$encryptedData = $this->make_request($encryptUrl,null);
|
| 90 |
}else{
|
83 |
}else{
|
| 91 |
$notificationUrl = $notificationUrl.'?user_id='.$userId;
|
84 |
$notificationUrl = $notificationUrl.'?user_id='.$userId;
|
| 92 |
$encryptUrl = $encryptUrl.base64_encode($notificationUrl);
|
85 |
$encryptUrl = $encryptUrl.base64_encode($notificationUrl);
|
| 93 |
$encryptedData = $this->make_request($encryptUrl,null);
|
86 |
$encryptedData = $this->make_request($encryptUrl,null);
|
| 94 |
}
|
87 |
}
|
| 95 |
}
|
88 |
}
|
| 96 |
|
89 |
}
|
| 97 |
}
|
90 |
else{
|
| - |
|
91 |
$encryptedData = $this->defaultEncryptedMessage($userId);
|
| 98 |
}
|
92 |
}
|
| 99 |
}else{
|
93 |
}else{
|
| 100 |
$encryptedData = $this->defaultEncryptedMessage($userId);
|
94 |
$redirectFlag=true;
|
| 101 |
}
|
95 |
}
|
| 102 |
}
|
96 |
}
|
| 103 |
}
|
97 |
}
|
| 104 |
}
|
98 |
}
|
| 105 |
|
- |
|
| 106 |
if($redirectFlag){
|
99 |
if($redirectFlag){
|
| 107 |
$this->redirect(array('action'=>'error'));
|
100 |
$this->redirect(array('action'=>'error'));
|
| 108 |
}else{
|
101 |
}else{
|
| 109 |
$intentToSend = 'intent://pm1.in?key='.urlencode($encryptedData['result']['value']).'&campaign='.$campaignId.'&intent_type='.$notificationType.'#Intent;scheme=profitmandiapp;package=com.saholic.profittill;end';
|
102 |
$intentToSend = 'intent://pm1.in?key='.urlencode($encryptedData['result']['value']).'&campaign='.$campaignId.'&intent_type='.$notificationType.'#Intent;scheme=profitmandiapp;package=com.saholic.profittill;end';
|
| 110 |
if($expiryFlag){
|
103 |
if($expiryFlag){
|