From e51d5a1c89dbe3f58132be7bd615a3f0b7f12ef2 Mon Sep 17 00:00:00 2001 From: Jonathan Rosenbaum Date: Sat, 28 Feb 2015 03:08:26 +0000 Subject: [PATCH] Provides an interface to an email connector. Define a url for an email connector that will connect to an email list. The url can be a server:port, program, etc. Name (First, Last) email address, and connector password will be sent to the connector. The purpose of email connectors is to provide autonomy in the choice of email services and programs. E.g. mailman, googlegroups See ./examples for an example connector --- Connections/database_functions.php | 56 ++++++++++++++++++++++-------- Connections/waiver.txt | 4 +-- contact_add_edit.php | 4 +-- examples/cert.pem | 29 ++++++++++++++++ js/contact.js | 11 ++++-- json/contact.php | 29 ++++++++++++++++ 6 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 examples/cert.pem diff --git a/Connections/database_functions.php b/Connections/database_functions.php index 8a776c0..7d6639d 100644 --- a/Connections/database_functions.php +++ b/Connections/database_functions.php @@ -1,6 +1,27 @@ 0){ $shop_id = $_GET['shop_id']; } else { @@ -210,7 +209,8 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1); -
+
+ diff --git a/examples/cert.pem b/examples/cert.pem new file mode 100644 index 0000000..25f7dfb --- /dev/null +++ b/examples/cert.pem @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIFAjCCA+qgAwIBAgIJAP6Z46+0uNaRMA0GCSqGSIb3DQEBBQUAMIGwMQswCQYD +VQQGEwJVUzELMAkGA1UECBMCV1YxEzARBgNVBAcTCk1vcmdhbnRvd24xHjAcBgNV +BAoTFUZyZWUgU29mdHdhcmUgUEMsIExMQzEeMBwGA1UECxMVd3Zjb21wbGV0ZXN0 +cmVldHMub3JnMR4wHAYDVQQDExV3dmNvbXBsZXRlc3RyZWV0cy5vcmcxHzAdBgkq +hkiG9w0BCQEWEGdudXNlckBnbWFpbC5jb20wIBcNMTUwMjI4MDIwNjE1WhgPMjA3 +NTAyMTMwMjA2MTVaMIGwMQswCQYDVQQGEwJVUzELMAkGA1UECBMCV1YxEzARBgNV +BAcT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g94dNyjPgwvMRlPGsIsmfDvyJbkC +aOCWXUNhbeS8GM+/deI6KxpfsWwGOQ/JYjlKBtTivGKg2GD7dP/c3FdxXR/kGX6C +1un/8udfhkx+xfngVPCsMTcYbfwW54K6m8DyykJiEjAVZMg4M8CvwDxd4vIBDfFb +soCSzGGZvQWkwier2o+uPcBgiQlOQjI7Lj4r3h9Od1gfBfS6GW7GVeU5L+Q/SFUd +Q2yPGyDiqiTE3Ym0rue8wvAWdlnpkvN9YyodaD3UAH1s8835i94= +-----END CERTIFICATE----- diff --git a/js/contact.js b/js/contact.js index 5f40305..a6a3b28 100644 --- a/js/contact.js +++ b/js/contact.js @@ -89,7 +89,7 @@ $(function(){ if ((err0 + err1 + err2 + err3 + err4 + err5) > 0 ) { } else { - //e.preventDefault(); + e.preventDefault(); dfd.resolve("Success"); } @@ -116,7 +116,14 @@ $(function(){ } else if (waiver === false) { waiver = 0; } - $.post("json/contact.php", {contact_id: contact_id, email_list: email_list , waiver: waiver }); + // update receive_newsletter and waiver in the database + $.post("json/contact.php", {contact_id: contact_id, email_list: email_list, waiver: waiver }); + + // email subscribe + if (email_list == 1) { + $.post("json/contact.php", {email_list_connector: 1, email: email.val(), + first_name: first_name.val(), last_name: last_name.val()}); + } } diff --git a/json/contact.php b/json/contact.php index 0db796f..2d77504 100644 --- a/json/contact.php +++ b/json/contact.php @@ -3,6 +3,9 @@ require_once('../Connections/database_functions.php'); require_once('../Connections/YBDB.php'); mysql_select_db($database_YBDB, $YBDB); +$email_list_connector = EMAIL_LIST_CONNECTOR; +$email_list_connector_password = EMAIL_LIST_CONNECTOR_PASSWORD; +$ssl_certificate = SSL_CERTIFICATE; // update waiver if( isset($_POST['waiver']) ) { @@ -45,5 +48,31 @@ mysql_select_db($database_YBDB, $YBDB); } + // send data to connector (local or remote) + if (isset($_POST['email_list_connector'])) { + + $ch = curl_init(); + $curlConfig = array( + CURLOPT_URL => $email_list_connector . '/api/parsetime', + CURLOPT_POST => true, + CURLOPT_SSL_VERIFYPEER => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POSTFIELDS => array( + 'password' => $email_list_connector_password, + ), + ); + + if ($ssl_certificate) { + $curlConfig[CURLOPT_CAINFO] = $ssl_certificate; + } + + curl_setopt_array($ch, $curlConfig); + $result = curl_exec($ch); + curl_close($ch); + + echo $result; + + } + ?> \ No newline at end of file