From b72d6d806536af29f5cc516470db54af949be4d1 Mon Sep 17 00:00:00 2001
From: prashantsinalkar
Date: Thu, 14 Jan 2016 14:25:12 +0530
Subject: changes done in according to multiple events
---
unsubscribe.php | 143 ++++++++++++++++++++++++++++++++++----------------------
1 file changed, 88 insertions(+), 55 deletions(-)
diff --git a/unsubscribe.php b/unsubscribe.php
index f72f49a..e4d6a44 100755
--- a/unsubscribe.php
+++ b/unsubscribe.php
@@ -1,60 +1,93 @@
prepare($sql);
- $q->execute(array('email_id_hash'=>$email_id_hash));
-
-
- while($data = $q->fetchAll(PDO::FETCH_ASSOC)) {
- foreach($data as $row){
-
-
- if($data != NULL){
-
- if($row['unsubscribe'] == 0 && $row['email_hash'] == $email_id_hash){
-
- $sql_up = "UPDATE sent_email SET unsubscribe = 1 WHERE email_hash =:email_id_hash ";
- $q_up = $conn->prepare($sql_up);
- $q_up->execute(array(':email_id_hash'=>$email_id_hash));
-
- echo '
Thank You for unsubscription';
- echo '
If you are not automatically redirected, click here: SciPy India 2015.';
- }
-
- elseif($row['unsubscribe'] == 1 && $row['email_hash'] == $email_id_hash){
- echo '
You are already unsubscribed!';
- echo '
If you are not automatically redirected, click here: SciPy India 2015.';
+ $email_id_hash = $_GET['key'];
+ $event = $_GET['event'];
+ unsubscribeEmailid($email_id_hash, $event);
+ }
+ else
+ {
+ echo 'wrong link';
+ }
+ function unsubscribeEmailid($email_id_hash, $event)
+ {
+ global $conn;
+ // try to update user with specified information
+ $email_id_hash = urldecode($email_id_hash);
+ $sql = "SELECT email, unsubscribe, email_hash FROM sent_email WHERE email_hash = :email_id_hash AND event= :event";
+ $q = $conn->prepare($sql);
+ $q->execute(array(
+ 'email_id_hash' => $email_id_hash,
+ 'event' => $event
+ ));
+ while ($data = $q->fetchAll(PDO::FETCH_ASSOC))
+ {
+ foreach ($data as $row)
+ {
+ if ($data != NULL)
+ {
+ switch ($event)
+ {
+ case 'scipy 2015':
+ if ($row['unsubscribe'] == 0 && $row['email_hash'] == $email_id_hash)
+ {
+ $sql_up = "UPDATE sent_email SET unsubscribe = 1 WHERE email_hash =:email_id_hash ";
+ $q_up = $conn->prepare($sql_up);
+ $q_up->execute(array(
+ ':email_id_hash' => $email_id_hash
+ ));
+ echo '
Thank You for unsubscription';
+ echo '
If you are not automatically redirected, click here: SciPy India 2015.';
+ header('Refresh: 3; URL=http://scipy.in');
+ }
+ elseif ($row['unsubscribe'] == 1 && $row['email_hash'] == $email_id_hash)
+ {
+ echo '
You are already unsubscribed!';
+ echo '
If you are not automatically redirected, click here: SciPy India 2015.';
+ header('Refresh: 3; URL=http://scipy.in');
+ }
+ else
+ {
+ echo '
You are not a subscriber!';
+ echo '
If you are not automatically redirected, click here: SciPy India 2015.';
+ header('Refresh: 3; URL=http://scipy.in');
+ }
+ break;
+ case 'cfd-openfoam-symposium 2016':
+ if ($row['unsubscribe'] == 0 && $row['email_hash'] == $email_id_hash)
+ {
+ $sql_up = "UPDATE sent_email SET unsubscribe = 1 WHERE email_hash =:email_id_hash";
+ $q_up = $conn->prepare($sql_up);
+ $q_up->execute(array(
+ ':email_id_hash' => $email_id_hash
+ ));
+ echo '
Thank You for unsubscription';
+ echo '
If you are not automatically redirected, click here: OpenFOAM Symposium 2016.';
+ header('Refresh: 3; URL=http://fossee.in/conference/cfd-symposium/');
+ }
+ elseif ($row['unsubscribe'] == 1 && $row['email_hash'] == $email_id_hash)
+ {
+ echo '
You are already unsubscribed!';
+ echo '
If you are not automatically redirected, click here: OpenFOAM Symposium 2016.';
+ header('Refresh: 3; URL=http://fossee.in/conference/cfd-symposium/');
+ }
+ else
+ {
+ echo '
You are not a subscriber!';
+ echo '
If you are not automatically redirected, click here: OpenFOAM Symposium 2016.';
+ header('Refresh: 3; URL=http://fossee.in/conference/cfd-symposium/');
+ }
+ break;
+ }
+ }
+ else
+ {
+ echo "Wrong Link please try again";
+ header('Refresh: 3; URL=http://fossee.in');
+ }
}
-
- else{
- echo '
You are not a subscriber!';
- echo '
If you are not automatically redirected, click here: SciPy India 2015.';
- }
-
- }else{
-
- echo "Wrong Link please try again";
- }
+ }
}
- }
-}
-
-$conn=null;
+ $conn = null;
?>
--
cgit