#print_r($_POST); #TODO deactivate proxy, logs and prices for all owned wms #TODO #$wms_list=array2str($ownwms); #print $wms_list; //$admin->unsetWmsProxy($wms_list);#TODO not delete owsproxy urls but update each entry! -> this would not delete log or usage of proxy!!! #serialize ownwms - to list and do sql #for the definitions in the form set the params #sequentialy read out the post variables foreach ($_POST as $var => $value) { #select those which are relevant (hidden fields for proxy and log) #identify them $parts = explode("_", $var); #echo "All vars: <br>"; #echo $var." = ".$value."<br>"; $value = validateint($value); if ($parts[0] != 'status' && $parts[2] == 'price') { #for the pricing in the textfield $admin->setWmsPrice(intval($value), intval($parts[1])); } #check the hidden fields if some log should be set if ($parts[2] == 'log' && $parts[0] == 'status') { #set the log value to 1 or 0 $admin->setWmsLogTag(intval($parts[1]), $value); #if value is 0 then set the price to 0 to. there would be is no sense to have a price set - maybe change this behavior if ($value == 0) { $admin->setWmsPrice(intval($value), intval($parts[1])); } #echo "log: $var = $value<br>"; } #check proxy fields
function SF_Account_Upsert166($entry, $form) { //upload information to salesforce from the final form. global $wpdb; ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******"; //- variable that contains your Salesforce.com password $TOKEN = "qhO7UhNTUrYp8XU5eF1SRomDp"; //- variable that contains your Salesforce.com password require_once ABSPATH . '/soapclient/SforceEnterpriseClient.php'; require_once ABSPATH . '/soapclient/SforceHeaderOptions.php'; // Salesforce Login information $wsdl = ABSPATH . '/soapclient/eSNenterprise.wsdl.xml'; $mySforceConnectionu = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnectionu->createConnection($wsdl); $mylogin = $mySforceConnectionu->login($USERNAME, $PASSWORD . $TOKEN); $loginname = $entry[30]; $thenewuser = get_user_by('login', $loginname); if ($thenewuser) { $user_id = $thenewuser->ID; } else { sleep(1); $thenewuser = get_user_by('login', $loginname); $user_id = $thenewuser->ID; } $newperson = array(); $newperson['WP_Unique_ID__c'] = $user_id; $newperson['WP_ID__c'] = $user_id; $newperson['Source__c'] = $_SERVER["SERVER_NAME"]; $newperson['Site_Registered_On__c'] = $_SERVER["SERVER_NAME"]; $wp_subreq_id = '21' . $entry[4]; //21 = digital ecn [4] is email $newSubReq = array(); // array for subscription $newSubReq['Source__c'] = "Web"; //$newSubReq['WP_ID__c'] = $user_id; $newSubReq['WP_ID__c'] = substr($wp_subreq_id, 0, 20); //need to limit length to 20 characters $newSubReq["Sub_Status__c"] = 'Pending'; $newSubReq['Personal_Question__c'] = $entry[59]; $newSubReq['Promo_Code__c'] = "Registration"; $newSubReq['Renewal_Link__c'] = substr(${$entry}[18], 0, 254); $newSubReq['Request_Date__c'] = date("Y-m-d"); $newSubReq['Request_URL__c'] = $_SERVER["SERVER_NAME"]; $newSubReq["Name"] = 'eCampus News Digital Subscription'; if (!empty($entry[30])) { $newperson['WP_Login__c'] = strtolower($entry[30]); } if (!empty($entry[4])) { $newperson['PersonEmail'] = $entry[4]; $newSubReq['Email__c'] = $entry[4]; $newperson['Email_as_ExternalID__c'] = $entry[4]; //12-20-2011 } if (!empty($entry[1])) { $newperson['FirstName'] = $entry[1]; $newSubReq['First_Name__c'] = $entry[1]; } if (!empty($entry[2])) { $newperson['LastName'] = $entry[2]; $newSubReq['Last_Name__c'] = $entry[2]; } if (!empty($entry[61])) { $newperson['Unique_Title__c'] = $entry[61]; $newSubReq['Unique_Title__c'] = $entry[61]; } if (!empty($entry[3])) { $newperson['Organization__c'] = $entry[3]; $newSubReq['Organization__c'] = $entry[3]; } if (!empty($entry[5])) { $newperson['PersonTitle'] = $entry[5]; $newSubReq['Title__c'] = $entry[5]; } if (!empty($entry[6])) { $newperson['Company_Type__c'] = $entry[6]; $newSubReq['Organization_Type__c'] = $entry[6]; } if (!empty($entry[7])) { $newperson['PersonMailingStreet'] = $entry[7]; $newSubReq['Address1__c'] = $entry[7]; } if (!empty($entry[8])) { $newperson['Mailing_Address_2__c'] = $entry[8]; $newSubReq['Address2__c'] = $entry[8]; } if (!empty($entry[9])) { $newperson['PersonMailingCity'] = $entry[9]; $newSubReq['city__c'] = $entry[9]; } if (!empty($entry[10])) { $newperson['PersonMailingState'] = $entry[10]; $newSubReq['State__c'] = $entry[10]; } if (!empty($entry[12])) { $newperson['PersonMailingPostalCode'] = $entry[12]; $newSubReq['Zip__c'] = $entry[12]; } if (!empty($entry[13])) { $newperson['PersonMailingCountry'] = $entry[13]; $newSubReq['Country__c'] = $entry[13]; } if (!empty($entry[22])) { $newperson['Phone'] = $entry[22]; $newSubReq['Phone__c'] = $entry[22]; } if (!empty($entry[31])) { $newperson['Fax'] = $entry[31]; $newSubReq['Fax__c'] = $entry[31]; } if (!empty($entry[32])) { $newperson['Grade_Level__c'] = $entry[32]; } else { $newperson['Grade_Level__c'] = ""; } if (!empty($entry[33])) { $newperson['Subject_Taught__c'] = $entry[33]; } else { $newperson['Subject_Taught__c'] = ""; } if (!empty($entry[14])) { $newSubReq['Personal_Answer__c'] = $entry[14]; } $OptedOutflag = 0; if (!empty($entry['57.1'])) { $newperson['ecn_today__c'] = $entry['57.1']; if ($entry['57.1'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['ecn_today__c'] = "Not Subscribed"; } if (!empty($entry['57.2'])) { $newperson['eCN_This_Week__c'] = $entry['57.2']; if ($entry['57.2'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_This_Week__c'] = "Not Subscribed"; } // <span style="cursor:Pointer;" title="Weekly on Wednesday"> eCampus IT Leadership<img src="/wp-content/themes/advanced-newspaper/images/info14.gif" /></span>|Subscribed if (!empty($entry['57.3'])) { $newperson['eCN_IT_School_Leadership__c'] = $entry['57.3']; if ($entry['57.3'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_IT_School_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.4'])) { $newperson['eCN_Offers__c'] = $entry['57.4']; if ($entry['57.4'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_Offers__c'] = "Not Subscribed"; } if (!empty($entry['57.5'])) { $newperson['eCN_Partners__c'] = $entry['57.5']; if ($entry['57.5'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_Partners__c'] = "Not Subscribed"; } $newperson['eSN_Today__c'] = "Not Subscribed"; $newperson['eSN_Tools_For_Schools__c'] = "Not Subscribed"; $newperson['Ed_Resource_Alert__c'] = "Not Subscribed"; $newperson['eClassroom_News__c'] = "Not Subscribed"; $newperson['eSN_This_Week__c'] = "Not Subscribed"; $newperson['eSN_Offers__c'] = "Not Subscribed"; $newperson['Partner_Offers__c'] = "Not Subscribed"; //special update unsub flag if they subscribe to anything... else do not change it. if ($OptedOutflag == 1) { $newperson['PersonHasOptedOutOfEmail'] = false; } $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); //When if ($upsertResponse->success == 1) { update_user_meta($user_id, "sfid", $upsertResponse->id); update_user_meta($user_id, "PersonContactId", $upsertResponse->id); $newSubReq['Person_Account__c'] = $upsertResponse->id; //now that we have a new user account put in the my eschool news data if it is set $esm_change = '6|1|'; $seperator = ','; if (isset($_POST[input_54_1]) and $_POST[input_54_1] == 213) { $esm_change .= '213,'; } if (isset($_POST[input_54_2]) and $_POST[input_54_2] == 27) { $esm_change .= '27,'; } if (isset($_POST[input_54_3]) and $_POST[input_54_3] == 4) { $esm_change .= '4,'; } if (isset($_POST[input_54_4]) and $_POST[input_54_4] == 5351) { $esm_change .= '5351,'; } if (isset($_POST[input_54_5]) and $_POST[input_54_5] == 2303) { $esm_change .= '2303,'; } if (isset($_POST[input_54_6]) and $_POST[input_54_6] == 43) { $esm_change .= '43,'; } if (isset($_POST[input_54_7]) and $_POST[input_54_7] == 215) { $esm_change .= '215,'; } if (isset($_POST[input_54_8]) and $_POST[input_54_8] == 4217) { $esm_change .= '4217,'; } if (isset($_POST[input_54_9]) and $_POST[input_54_9] == 28) { $esm_change .= '28,'; } if (isset($_POST[input_54_11]) and $_POST[input_54_11] == 9) { $esm_change .= '9,'; } if (isset($_POST[input_54_12]) and $_POST[input_54_12] == 26) { $esm_change .= '26,'; } if (isset($_POST[input_54_13]) and $_POST[input_54_13] == 872) { $esm_change .= '872,'; } if (isset($_POST[input_54_14]) and $_POST[input_54_14] == 3) { $esm_change .= '3,'; } if (isset($_POST[input_54_15]) and $_POST[input_54_15] == 11) { $esm_change .= '11,'; } $esm_change = trim($esm_change, $seperator); $key = '_myesm_esn'; $single = true; update_user_meta($user_id, $key, $esm_change); //we did it so keep little data on the server... } else { //try again in one second... sleep(1); $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); if ($upsertResponse->success == 1) { update_user_meta($user_id, "sfid", $upsertResponse->id); update_user_meta($user_id, "PersonContactId", $upsertResponse->id); $newSubReq['Person_Account__c'] = $upsertResponse->id; //now that we have a new user account put in the my eschool news data if it is set $esm_change = '6|1|'; $seperator = ','; if (isset($_POST[input_54_1]) and $_POST[input_54_1] == 213) { $esm_change .= '213,'; } if (isset($_POST[input_54_2]) and $_POST[input_54_2] == 27) { $esm_change .= '27,'; } if (isset($_POST[input_54_3]) and $_POST[input_54_3] == 4) { $esm_change .= '4,'; } if (isset($_POST[input_54_4]) and $_POST[input_54_4] == 5351) { $esm_change .= '5351,'; } if (isset($_POST[input_54_5]) and $_POST[input_54_5] == 2303) { $esm_change .= '2303,'; } if (isset($_POST[input_54_6]) and $_POST[input_54_6] == 43) { $esm_change .= '43,'; } if (isset($_POST[input_54_7]) and $_POST[input_54_7] == 215) { $esm_change .= '215,'; } if (isset($_POST[input_54_8]) and $_POST[input_54_8] == 4217) { $esm_change .= '4217,'; } if (isset($_POST[input_54_9]) and $_POST[input_54_9] == 28) { $esm_change .= '28,'; } if (isset($_POST[input_54_11]) and $_POST[input_54_11] == 9) { $esm_change .= '9,'; } if (isset($_POST[input_54_12]) and $_POST[input_54_12] == 26) { $esm_change .= '26,'; } if (isset($_POST[input_54_13]) and $_POST[input_54_13] == 872) { $esm_change .= '872,'; } if (isset($_POST[input_54_14]) and $_POST[input_54_14] == 3) { $esm_change .= '3,'; } if (isset($_POST[input_54_15]) and $_POST[input_54_15] == 11) { $esm_change .= '11,'; } $esm_change = trim($esm_change, $seperator); $key = '_myesm_esn'; $single = true; update_user_meta($user_id, $key, $esm_change); } else { //mail('*****@*****.**','SF User UPloaded FAILED 2nd try',print_r($sfaccountresponse)); } } if (!empty($entry[48])) { //check if they want the pub, if so upload it, in a custom object so we cannot just add it if it is eSchool News. if ($entry[48] == 'Yes') { // add subscription $upsertResponse2 = $mySforceConnectionu->upsert('WP_ID__c', array($newSubReq), 'Subscription_Request__c'); if ($upsertResponse2->success == 1) { } else { //try again sleep(1); $upsertResponse2 = $mySforceConnectionu->upsert('WP_ID__c', array($newSubReq), 'Subscription_Request__c'); } } } $user_login = $entry[30]; //use the input if of the username $user_pass = $entry[47]; //use the input if of the password //pass the above to the wp_signon function $user = wp_signon(array('user_login' => $user_login, 'user_password' => $user_pass, 'remember' => true)); //check if we need to give a message. if (!empty($entry[48]) and $entry[48] == 'No') { if ($upsertResponse->success == 1) { if ($_GET['redirect_to']) { $redirectto = $_GET['redirect_to']; $reditchk = strpos($redirectto, "eschoolnews"); if ($reditchk > 1) { //we are ok no need to do anything... } else { $redirectto = 'http://www.eschoolnews.com/'; } wp_safe_redirect($redirectto); sleep(2); exit; break; } } } else { if (!empty($entry[48])) { if ($upsertResponse2->success == 1) { if ($_GET['redirect_to']) { $redirectto = $_GET['redirect_to']; $reditchk = strpos($redirectto, "eschoolnews"); if ($reditchk > 1) { //we are ok no need to do anything... } else { $redirectto = 'http://www.eschoolnews.com/'; } wp_safe_redirect($redirectto); sleep(2); exit; break; } } } } $formsuccess = validateint($_GET['success']); }
<?php /* Template Name: MCH Sub Form */ global $theme_options, $newspaper, $user_ID, $wpdb, $showPromo, $source, $sfid; $URLUID = validateint($_GET['u']); $subtype = validateint($_GET['st']); $URLEmail = $_GET['em']; $sfid = $_GET['sfid']; $source = $_GET['pub']; $showPromo = $_GET['promo']; $promoCode = $_GET['promocode']; if ($source == 'ecampusnews') { $thepuboffer = 'ecn'; } elseif (strpos($_SERVER["SERVER_NAME"], "ecampusnews") !== false) { $thepuboffer = 'ecn'; } else { $thepuboffer = 'other'; } add_action("gform_post_submission_46", "SF_Account_Upsert", 10, 2); add_filter('gform_pre_render', 'remove_PromoCode'); //remove_PromoCode($form); function SF_Account_Upsert($entry, $form) { global $wpdb; $user_email = $entry[4]; ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******";
$unsub_eCN_IT_School_Leadership = 1; } if (isset($_POST['eSN_IT_School_Leadership'])) { $message = $message . ' eSN IT School Leadership, '; $unsub_eSN_IT_School_Leadership = 1; } mail('vcarlson@eschoolnews.com,ndavid@eschoolnews.com,jfesta@eschoolnews.com', 'FAILED UNSUBSCRIBE REQUEST EMAIL NOT FOUND IN WP SYSTEM', $message); $wpdb->query($wpdb->prepare("INSERT INTO emailsuppression (txtemail, dtdateadd, txtipaddress) VALUES (%s, %s, %s )", $unsubemailb, $dtDate, $message)); } } } else { $emailtounsubcheck = 0; } } } else { $unsublist = validateint($_GET['list']); $unsubemail = $_GET['em']; if ($unsublist > -1) { // The input is a valid positive integer, so we can now use it if ($unsublist == 100) { $eschool_news_this_week = 1; $hidesec2 = 1; } else { if ($unsublist == 101) { $eschool_news_today = 1; $hidesec2 = 1; } else { if ($unsublist == 102) { $eschool_news_tools_for_schools = 1; $hidesec2 = 1; } else {
function SF_Account_Upsert226($entry, $form) { global $wpdb; ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******"; //- variable that contains your Salesforce.com password $TOKEN = "qhO7UhNTUrYp8XU5eF1SRomDp"; //- variable that contains your Salesforce.com password require_once ABSPATH . '/soapclient/SforceEnterpriseClient.php'; require_once ABSPATH . '/soapclient/SforceHeaderOptions.php'; // Salesforce Login information $wsdl = ABSPATH . '/soapclient/eSNenterprise.wsdl.xml'; $mySforceConnectionu = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnectionu->createConnection($wsdl); $mylogin = $mySforceConnectionu->login($USERNAME, $PASSWORD . $TOKEN); $loginname = $entry[30]; $thenewuser = get_user_by('login', $loginname); if ($thenewuser) { $user_id = $thenewuser->ID; } else { sleep(1); $thenewuser = get_user_by('login', $loginname); $user_id = $thenewuser->ID; } $newperson = array(); $newperson['WP_Unique_ID__c'] = $user_id; $newperson['WP_ID__c'] = $user_id; $newperson['Source__c'] = $_SERVER["SERVER_NAME"]; $newperson['Site_Registered_On__c'] = $_SERVER["SERVER_NAME"]; $wp_subreq_id = '21' . $entry[4]; //21 = digital ecn [4] is email if (!empty($entry[4])) { $newperson['PersonEmail'] = $entry[4]; $newSubReq['Email__c'] = $entry[4]; $newperson['Email_as_ExternalID__c'] = $entry[4]; } if (!empty($entry[1])) { $newperson['FirstName'] = $entry[1]; $newSubReq['First_Name__c'] = $entry[1]; } if (!empty($entry[2])) { $newperson['LastName'] = $entry[2]; $newSubReq['Last_Name__c'] = $entry[2]; } if (!empty($entry[61])) { $newperson['Unique_Title__c'] = $entry[61]; $newSubReq['Unique_Title__c'] = $entry[61]; } if (!empty($entry[5])) { $newperson['PersonTitle'] = $entry[5]; $newSubReq['Title__c'] = $entry[5]; } $OptedOutflag = 0; if (!empty($entry['57.1'])) { $newperson['eSN_This_Week__c'] = $entry['57.1']; if ($entry['57.1'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eSN_This_Week__c'] = "Not Subscribed"; } if (!empty($entry['57.2'])) { $newperson['eSN_Today__c'] = $entry['57.2']; if ($entry['57.2'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eSN_Today__c'] = "Not Subscribed"; } if (!empty($entry['57.3'])) { $newperson['eSN_IT_School_Leadership__c'] = $entry['57.3']; if ($entry['57.3'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eSN_IT_School_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.4'])) { /* Check on this field */ $newperson['MyeCN_EdTech_Leadership__c'] = $entry['57.4']; if ($entry['57.4'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['MyeCN_EdTech_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.5'])) { $newperson['eCN_Today__c'] = $entry['57.5']; if ($entry['57.5'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_Today__c'] = "Not Subscribed"; } if (!empty($entry['57.6'])) { $newperson['eCN_This_Week__c'] = $entry['57.6']; if ($entry['57.6'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_This_Week__c'] = "Not Subscribed"; } if (!empty($entry['57.7'])) { $newperson['eCN_IT_School_Leadership__c'] = $entry['57.7']; if ($entry['57.7'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_IT_School_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.8'])) { $newperson['eClassroom_News__c'] = $entry['57.8']; if ($entry['57.8'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eClassroom_News__c'] = "Not Subscribed"; } $newperson['eSN_Offers__c'] = "Not Subscribed"; $newperson['Partner_Offers__c'] = "Not Subscribed"; $newperson['eCN_Offers__c'] = "Not Subscribed"; $newperson['eCN_Partners__c'] = "Not Subscribed"; //special update unsub flag if they subscribe to anything... else do not change it. if ($OptedOutflag == 1) { $newperson['PersonHasOptedOutOfEmail'] = false; } $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); if ($upsertResponse->success == 1) { //Saved for later use mail('*****@*****.**', '226 SF Subscription request success', 'line 138'); } else { $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); mail('*****@*****.**', '226 SF Subscription request failed', 'line 142'); } $formsuccess = validateint($_GET['success']); }