function actionDefault() { // Show the current object YDDebugUtil::dump($this, 'Original object before encryption'); // Get the serialized version of ourselves //$data = $this->serialize(); YDDebugUtil::dump($this, 'Input data'); // Show the password we are using YDDebugUtil::dump(YD_SELF_SCRIPT, 'Encryption password'); // Encrypt the data $data_encrypted = YDEncryption::encrypt(YD_SELF_SCRIPT, $this); YDDebugUtil::dump($data_encrypted, 'Encrypted data'); // Decrypt the data $data_decrypted = YDEncryption::decrypt(YD_SELF_SCRIPT, $data_encrypted); //YDDebugUtil::dump( $data_decrypted, 'Decrypted data' ); // Show the decrypted object YDDebugUtil::dump($data_decrypted, 'Original object after decryption'); }
/** * This function returns a variable from the configuration. If the configuration variable doesn't exist or it's * a wrong password, it returns the default value if this value isn't null, otherwise returns a fatal error. * * @param $name The name of the configuration variable to retrieve. * @param $default (optional) If not null, this value will be returned if the configuration setting doesn't * exist in the configuration. * @param $passwd (optional) If not null, the data will be decrypted with this password. * * @returns The value of the configuration variable. */ function get($name, $default = null, $passwd = null) { // Initialize the store YDPersistent::_init(); // If the $_GET variable exists, return that one if (YDConfig::get('YD_ALLOW_OVERRIDE_QS', false) === true) { if (isset($_GET[$name]) === true) { YDPersistent::set($name, $_GET[$name], $passwd); } } // Check if the key exists if (!YDPersistent::exists($name)) { // Check if we have a default, if not, raise an error if (!is_null($default)) { return $default; } else { trigger_error('Persistent variable "' . $name . '" is not defined.', YD_ERROR); } } // Get the value $obj = $_COOKIE[YDConfig::get('YD_PERSISTENT_STORE_NAME')][$name]; // Decrypt the data if needed if (is_null($passwd) && !is_null(YDConfig::get('YD_PERSISTENT_DEFAULT_PASSWORD', null))) { $passwd = YDConfig::get('YD_PERSISTENT_DEFAULT_PASSWORD', null); } if (!is_null($passwd)) { $obj = YDEncryption::decrypt($passwd, $obj); } // Now, we need to base64 decode and unserialize $obj = @unserialize(base64_decode($obj)); // Return the default if decryption failed if (!$obj && !is_null($default)) { return $default; } // Return the object return $obj; }
/** * This function decrypts a value using the YD_CART_PASSWORD. * * @returns The decrypted value * @static */ function decrypt($value) { return YDEncryption::decrypt(YDConfig::get('YD_CART_PASSWORD'), $value); }