diff --git a/wp/wp-content/plugins/affiliate-host-n-post/host-n-post.php b/wp/wp-content/plugins/affiliate-host-n-post/host-n-post.php index 3c104db8..fb91e5f2 100644 --- a/wp/wp-content/plugins/affiliate-host-n-post/host-n-post.php +++ b/wp/wp-content/plugins/affiliate-host-n-post/host-n-post.php @@ -2,7 +2,7 @@ /* Plugin Name: Affiliate Host 'n Post Description: Handles form submissions and integrates with Salesforce and Five9 APIs. -Version: 1.1 +Version: 1.2 Author: Anthony Volpe */ @@ -12,18 +12,15 @@ define('LEAD_SOURCE', "Web"); define('MEMBER_STATUS', "Web response"); // Handle the Salesforce form submission -function postsf($data) -{ - // Fetch environment configuration - $salesforceEnvironment = get_option('select-environment'); +function postsf($data) { + + $sfdc_env = get_option('select-environment'); // Set up Salesforce configuration based on the environment - if ($salesforceEnvironment == 'staging') { - $Campaign_ID = '7011I000000dF9n'; + if ($sfdc_env == 'full') { $sfdc_oid = '00DDh0000009Umu'; $webtolead_url = 'https://test.salesforce.com/servlet/servlet.WebToLead'; } else { - $Campaign_ID = '7011I000000dDwA'; $sfdc_oid = '00D1I000000mJ0Q'; $webtolead_url = 'https://webto.salesforce.com/servlet/servlet.WebToLead'; } @@ -35,7 +32,7 @@ function postsf($data) 'phone' => sanitize_text_field($data['phone']), 'email' => sanitize_email($data['your-email']), 'zip' => sanitize_text_field($data['zip']), - 'Campaign_ID' => $Campaign_ID, // Dynamic Campaign ID + 'Campaign_ID' => sanitize_text_field($data['campaign_ID']), 'oid' => $sfdc_oid, // Dynamic OID based on environment 'lead_source' => LEAD_SOURCE, 'Custom_Field_1__c' => sanitize_text_field($data['subid1']), @@ -124,7 +121,6 @@ function post59($data) { return json_encode($parsed_response); } - // Register REST API route for form submission add_action('rest_api_init', function () { register_rest_route('affiliates/v1', '/form', array( @@ -134,6 +130,7 @@ add_action('rest_api_init', function () { )); }); + // Callback function to handle the form submission // Handle REST API response formatting function handle_form_submission($request) { @@ -143,6 +140,6 @@ function handle_form_submission($request) { return new WP_REST_Response(array( 'salesforce_response' => $response1 ? "Success" : "Failed", - 'five9_response' => strip_tags($response2) + 'five9_response' => strip_tags($response2) ), 200); } diff --git a/wp/wp-content/themes/medicalalert/functions.php b/wp/wp-content/themes/medicalalert/functions.php index e68a09a3..f2964fb2 100644 --- a/wp/wp-content/themes/medicalalert/functions.php +++ b/wp/wp-content/themes/medicalalert/functions.php @@ -1,6 +1,4 @@ encrption_key = get_option("encrption_key"); $this->signature_key = get_option("signature_key");*/ - $this->encrption_key = IPER_ENCRYPTION_KEY; - $this->signature_key = IPER_SIGNATURE_KEY; + $this->encrption_key = ENCRYPTION_KEY; + $this->signature_key = SIGNATURE_KEY; $this->cipher = 'AES-256-CBC'; } diff --git a/wp/wp-content/themes/medicalalert/helpers/secured-content.php b/wp/wp-content/themes/medicalalert/helpers/secured-content.php deleted file mode 100644 index d88204b2..00000000 --- a/wp/wp-content/themes/medicalalert/helpers/secured-content.php +++ /dev/null @@ -1,139 +0,0 @@ -encrption_key = get_option("encrption_key"); - $this->signature_key = get_option("signature_key");*/ - $this->encrption_key = IPER_ENCRYPTION_KEY; - $this->signature_key = IPER_SIGNATURE_KEY; - $this->cipher = 'AES-256-CBC'; - - } - - public function encode_content($raw_content) - { - $message_content = new MessageContent(); - $message_content->Body = $raw_content; - $message_content->Timestamp = date('Y-m-d H:i:s', time()); - $message_content->Uid = self::guid(); - - // create signature & pack message - $signed_message = new MessageContentSigned(); - $signed_message->Content = json_encode($message_content); - $signed_message->Signature = $this->generate_signature($signed_message->Content); - - // create initialization vector & encode data - $iv_size = 16; - $iv = openssl_random_pseudo_bytes($iv_size); - $key = base64_decode($this->encrption_key); - $data = json_encode($signed_message); - $padding = 16 - (strlen($data) % 16); - $data .= str_repeat(chr($padding), $padding); - $cipher_text = openssl_encrypt($data, $this->cipher, $key, OPENSSL_RAW_DATA, $iv); - - // store content inside an encrypted container - $encrypted_content = new EncryptedContent(); - $encrypted_content->IV = base64_encode($iv); - $encrypted_content->Data = base64_encode($cipher_text); - - return $encrypted_content; - } - - public function decode_content($encrypted_string) - { - $encrypted_content = json_decode($encrypted_string); - - // decode data - - $key = base64_decode($this->encrption_key); - $iv = base64_decode($encrypted_content->IV); - $message = openssl_decrypt(base64_decode($encrypted_content->Data), $this->cipher, $key, OPENSSL_RAW_DATA, $iv); - $message = json_decode(substr($message, 0)); - $signature = $this->generate_signature($message->Content); - - return json_decode($message->Content)->Body; - } - - private function generate_signature($message_content) - { - $private_key = openssl_get_privatekey($this->signature_key); - - openssl_sign($message_content, $signature, $this->signature_key, 'SHA256'); - - openssl_free_key($private_key); - - return base64_encode($signature); - } - - public static function guid() - { - if (function_exists('com_create_guid') === true) - { - return trim(com_create_guid(), '{}'); - } - - return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)); - } - } -} - - diff --git a/wp/wp-content/themes/medicalalert/helpers/sfconfig-prod.php b/wp/wp-content/themes/medicalalert/helpers/sfconfig-prod.php new file mode 100755 index 00000000..b6be8082 --- /dev/null +++ b/wp/wp-content/themes/medicalalert/helpers/sfconfig-prod.php @@ -0,0 +1,26 @@ +