-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynd.php
109 lines (85 loc) · 2.9 KB
/
dynd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php error_reporting(0);
ob_start();
session_start();
require_once("inc/config.inc.php");
require_once("inc/database.inc.php");
require_once("inc/functions.inc.php");
$returnjson=array("status" => '0',"message" => 'Invalid Request',"redirecturl" => '');
if (!$_SERVER['REQUEST_METHOD'] === 'POST') {
$returnjson=array("status" => '0',"message" => 'Invalid Request',"redirecturl" => '');
echo json_encode($returnjson);
exit();
}
else if(isset($_REQUEST["qry"]) && $_REQUEST["qry"]=="subscription"){
$MAIL_ATTACHMENT=NULL;
$error_msg='';
$status=0;
$message='';
$db=new Database();
$db->open();
$reqval=array("subscriber_name" =>"","subscriber_email" =>"","id" =>"");
foreach($reqval as $key => $val){
if(isset($_REQUEST[$key])){
$reqval[$key]=(trim($_REQUEST[$key]));
}
}
if($db->isFound(_DB_PREFIX."subscription","subscriber_email='".$reqval["subscriber_email"]."'")){
$message='<div class="alert alert-danger">Already Subscribed</div>';
$status=0;
}
else{
require_once("inc/mail-formate-util.php");
$sql="INSERT INTO "._DB_PREFIX."subscription(subscriber_name, subscriber_email, subscribedatetime) ".
" VALUES('".$reqval["subscriber_name"]."', '".$reqval["subscriber_email"]."', now())";
$affectedrows=$db->query($sql);
if($affectedrows > 0){
$reqval["id"]=$db->insertID();
$return_mail_param=getSubsMailFormat($reqval);
$SUBJECT=$return_mail_param['mail_subject'];
$MAIL_BODY=$return_mail_param['mail_message'];
$BCC=NULL;//array(_BCC_EMAIL_);
$mailack=sendSmtpMail($reqval["subscriber_email"],$reqval["subscriber_name"],_NL_EMAIL,_NL_FROM,$SUBJECT,$MAIL_BODY,NULL,$BCC,$MAIL_ATTACHMENT);
if($mailack=="send"){
$message='<div class="alert alert-success">Subcribed Successfully</div>';
$status=1;
}
else{
$message='<div class="alert alert-danger">Subscribing failed'.$mailack.'</div>';
$status=0;
}
}
else{
$message='<div class="alert alert-danger">Subscribing failed try later...</div>';
$status=0;
}
}
$returnjson=array("status" => $status,"message" => $message,"redirecturl" => '');
echo json_encode($returnjson);
exit();
}
else if(isset($_REQUEST["qry"]) && $_REQUEST["qry"]=="unsubscribe"){
$status=0;
$message='';
$db=new Database();
$db->open();
$reqval=array("id" =>"");
foreach($reqval as $key => $val){
if(isset($_REQUEST[$key])){
$reqval[$key]=(trim($_REQUEST[$key]));
}
}
$sql="update "._DB_PREFIX."subscription set ispublish=0,unsubscribedatetime=now() where id=".$reqval["id"];
$affectedrows=$db->query($sql);
if($affectedrows > 0){
$message='<div class="alert alert-success">Newsletter Unsubscribe successfuly</div>';
$status=1;
}
else{
$message='<div class="alert alert-danger">Unsubscribing process failed try later...</div>';
$status=0;
}
$returnjson=array("status" => $status,"message" => $message,"redirecturl" => '');
echo json_encode($returnjson);
exit();
}
?>