public static function decrypt($str) { if (Urlcrypt::$key === "") { throw new Exception('No key provided.'); } $key = pack('H*', Urlcrypt::$key); $str = Urlcrypt::decode($str); $iv_size = mcrypt_get_iv_size(Urlcrypt::$cipher, Urlcrypt::$mode); $iv_dec = substr($str, 0, $iv_size); $str = substr($str, $iv_size); $str = mcrypt_decrypt(Urlcrypt::$cipher, $key, $str, Urlcrypt::$mode, $iv_dec); // http://jonathonhill.net/2013-04-05/write-tests-you-might-learn-somethin/ return rtrim($str, ""); }
public function buildUserLink($retailerID) { return 'member.php?uid=' . Urlcrypt::encode($retailerID); }
/* TODO: Add code here */ require 'config/globalconfig.php'; include_once 'include/_permission.inc'; include_once 'class/model_articletype.php'; include_once 'class/model_product.php'; include_once 'class/model_user.php'; include_once 'class/model_article.php'; include_once 'class/model_manufactory.php'; include_once 'class/model_retailer.php'; include_once 'class/model_status.php'; $objProduct = new Model_Product($objConnection); $objUser = new Model_User($objConnection); $objRetailer = new Model_Retailer($objConnection); $_SESSION[global_common::SES_LAST_PAGE] = $_SESSION[global_common::SES_C_CUR_PAGE]; $page = $_pgR["p"] ? $_pgR["p"] : 1; $userID = Urlcrypt::decode($_pgR["uid"]); $allRetailers = $objRetailer->getRetailerByUser($page, $userID, global_mapping::ProductID . ',' . global_mapping::RetailerID . ',' . global_mapping::ProductStatusID . ',' . global_mapping::Price . ',' . global_mapping::StatusDetail . ',' . global_mapping::ShortDesc . ',' . global_mapping::ShippingDesc . ',' . global_mapping::BoxInfo . ',' . global_mapping::CreatedBy . ',' . global_mapping::ModifiedDate . ',' . global_mapping::StatusID, $total); ?> <?php include_once 'include/_header.inc'; ?> <script type="text/javascript" src="<?php echo $_objSystem->locateJs('user_user.js'); ?> "></script> <script type="text/javascript" src="<?php echo $_objSystem->locateJs('user_retailer.js'); ?> "></script> <div id="profile-page" class="page-content">
private function deo($str) { $this->assertEquals($str, Urlcrypt::decode(Urlcrypt::encode($str))); }
} public static function encrypt($str) { if (self::$key === "") { throw new \Exception('No key provided.'); } $key = pack('H*', self::$key); $iv_size = mcrypt_get_iv_size(self::$cipher, self::$mode); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $str = utf8_encode($str); $ciphertext = mcrypt_encrypt(self::$cipher, $key, $str, self::$mode, $iv); $ciphertext = $iv . $ciphertext; return self::encode($ciphertext); } public static function decrypt($str) { if (self::$key === "") { throw new \Exception('No key provided.'); } $key = pack('H*', self::$key); $str = self::decode($str); $iv_size = mcrypt_get_iv_size(self::$cipher, self::$mode); $iv_dec = substr($str, 0, $iv_size); $str = substr($str, $iv_size); $str = mcrypt_decrypt(self::$cipher, $key, $str, self::$mode, $iv_dec); // http://jonathonhill.net/2013-04-05/write-tests-you-might-learn-somethin/ return rtrim($str, ""); } } Urlcrypt::$table = str_split(Urlcrypt::$table, 1);