public function index() { // handle POST from FoxyCart API transaction if (isset($_POST["FoxyData"]) or isset($_POST['FoxySubscriptionData'])) { $FoxyData_encrypted = isset($_POST["FoxyData"]) ? urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]); $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(), $FoxyData_encrypted); self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); // extend to allow for additional integrations with Datafeed $this->extend('addIntegrations', $FoxyData_encrypted); return 'foxy'; } else { return "No FoxyData or FoxySubscriptionData received."; } }
function decryptAndSplit($string) { $weekiwaawoo = "d0ntw0rryab0utit"; $source = pack("H*", $string); $decrypted = rc4crypt::decrypt($weekiwaawoo, $source); parse_str($decrypted, $valueArray); return $valueArray; $testString = substr($decoded, 0, strrpos($decoded, "&")); //check that the dataString is legimate if ($valueArray["nonce"] == md5($testString)) { //the data string has not been tampered with return $valueArray; } else { //the data string has failed the integrity check, abort output('<result success="false" error="INVALID" />', true); } }
public function actionWebhook() { $this->requirePostRequest(); craft()->log->removeRoute('WebLogRoute'); craft()->log->removeRoute('ProfileLogRoute'); if (isset($_POST["FoxyData"]) || isset($_POST['FoxySubscriptionData'])) { $encrypted = isset($_POST["FoxyData"]) ? urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]); $decrypted = \rc4crypt::decrypt($this->apikey, $encrypted); $xml = new \SimpleXMLElement($decrypted); $feedType = isset($_POST['FoxySubscriptionData']) ? "subscription" : "transaction"; if (craft()->foxyCart->processWebhook($xml, $feedType)) { $message = 'foxy'; } else { $message = 'Error processing webhook. Please consult your Craft logs'; } } else { $message = "No FoxyData or FoxySubscriptionData received."; } exit($message); }
function foxyshop_decrypt($src) { global $foxyshop_settings; return rc4crypt::decrypt($foxyshop_settings['api_key'], urldecode($src)); }
/** * Decrypt the given value using the mcrypt library function. * * If the mcrypt functions do not exist, we fallback to the RC4 implementation which is shipped with Zikula. * * @param string $value The value we wish to decrypt. * @param string $key The encryption key to use (optional) (default=null). * @param string $alg The encryption algirthm to use (only used with mcrypt functions) (optional) (default=null, signifies MCRYPT_RIJNDAEL_128). * @param boolean $encoded Whether or not the value is base64 encoded (optional) (default=true). * * @return string The decrypted value. */ public static function decrypt($value, $key = null, $alg = null, $encoded = true) { $res = false; $key = $key ? $key : 'ZikulaEncryptionKey'; $val = $encoded ? self::decode($value) : $value; if (function_exists('mcrypt_create_iv') && function_exists('mcrypt_decrypt')) { $alg = $alg ? $alg : MCRYPT_RIJNDAEL_128; $iv = mcrypt_create_iv(mcrypt_get_iv_size($alg, MCRYPT_MODE_ECB), crc32($key)); $res = mcrypt_decrypt($alg, $key, $val, MCRYPT_MODE_CBC); } else { require_once ZLOADER . '/vendor/encryption/rc4crypt.class.php'; $res = rc4crypt::decrypt($key, $val); } return $res; }
function mapAddressToDB($address_fields, $prefix = OSCommerce::ADDRESS_BOOK) { $rtn = array(); foreach (FoxydataUtils::$CustomerAddressFieldMap as $feed_field => $db_field) { $rtn[$prefix . $db_field] = $address_fields[$feed_field]; } $country = $this->osc->findCountryByCode($address_fields['country']); $rtn[$prefix . 'country_id'] = $country['countries_id']; $zone = $this->osc->findZoneByNameAndCountryID($address_fields['state'], $rtn[$prefix . 'country_id']); $rtn[$prefix . 'zone_id'] = $zone['zone_id']; return $rtn; } } $utils = new FoxydataUtils($osc); $decryptor = new rc4crypt(); $FoxyData = $decryptor->decrypt(DATAFEED_KEY, urldecode($_POST["FoxyData"])); $data = new XMLParser($FoxyData); // Parse that XML. $data->Parse(); /** * Wrapper class to make retrieving name / value pairs from an XML feed much * more concise. Create with an XMLTag (the result of parsing an XML * file), then retrieve properties with, e.g., $wrapper->customers_email_address. */ class PropertyWrapper { public function __construct(XMLTag $data) { $this->data = $data; } public function __get($field)
*/ $Use_Custom_Field = true; $Custom_Field = 'Subscribe'; // Name of the custom "Opt In" field during checkout. $Custom_Field_Value = 'yes'; // The value of the custom field that indicates the customer's agreement. $key = 'CHANGE THIS TEXT to your own datafeed keyphrase'; isset($_POST['FoxyData']) or die("error"); // Make sure we got passed some FoxyData function fatal_error_handler($errno, $errstr, $errfile, $errline, $errcontext) { die($errstr); return true; } set_error_handler('fatal_error_handler'); $FoxyData = rc4crypt::decrypt($key, urldecode($_POST["FoxyData"])); $data = new XMLParser($FoxyData); // Parse that XML. $data->Parse(); foreach ($data->document->transactions[0]->transaction as $tx) { $subscribe = !$Use_Custom_Field; if ($Use_Custom_Field) { foreach ($tx->custom_fields[0]->custom_field as $field) { $subscribe = $subscribe || $field->custom_field_name[0]->tagData == $Custom_Field && $field->custom_field_value[0]->tagData == $Custom_Field_Value; } } if ($subscribe) { subscribe_user_to_list(array('first_name' => $tx->customer_first_name[0]->tagData, 'last_name' => $tx->customer_last_name[0]->tagData, 'email' => $tx->customer_email[0]->tagData), $ListName, $ConstantContact_Auth); } } print "foxy";
} $products[] = $product; } return $products; } function fu_error_handler($errno, $message, $file, $line) { if ($errno < E_WARNING) { // This is stupid, E_ERROR < E_WARNING throw new Exception("{$errno} {$message} at {$file}:{$line}"); } } set_error_handler(fu_error_handler); if (isset($_POST['FoxyData'])) { // Receiving transmission from FoxyCart... $FoxyData = rc4crypt::decrypt($preferences->shared_secret, urldecode($_POST["FoxyData"])); $document = new SimpleXMLElement($FoxyData); $order_index = 0; foreach ($document->transactions->transaction as $transaction) { $order = array(); $shipToBilling = $order['ship_to_billing'] = empty($transaction->shipping_address1); try { foreach ($transaction as $field => $value) { if ($field == $OrderItemsField) { $order[$FieldsRenamed[$field]] = extractProducts($value); } else { if (in_array($field, $FieldsRenamed) && !empty($value)) { $order[$FieldsRenamed[$field]] = (string) $value; } else { if (in_array($field, $ShippingAddressFields) && !$order['ship_to_billing'] && !empty($value)) { $order[$field] = (string) $value;