v7‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT home/ajdemo/public_html/mempro/application/cc/library/CcRecord.php000064400000006565152101633650021303 0ustar00_cc_code; } function setCvv($code) { $this->_cc_code = filterId($code); } function maskCc($number) { $number = preg_replace('/\D+/', '', $number); if (strlen($number)<8) return '****************'; return str_repeat('*', strlen($number)-4) . substr($number, -4, 4); } function toRow() { $arr = parent::toRow(); // fields to encrypt if (isset($arr['cc_number'])) { $arr['cc_number'] = preg_replace('/\D+/', '', $arr['cc_number']); if (empty($arr['cc']) || ($arr['cc_number'] != '0000000000000000')) $arr['cc'] = $this->maskCc($arr['cc_number']); } foreach ($this->_encryptedFields as $f) if (array_key_exists($f, $arr)) $arr[$f] = $this->_table->encrypt($arr[$f]); return $arr; } public function fromRow(array $arr) { // fields to decrypt foreach ($this->_encryptedFields as $f) if (array_key_exists($f, $arr)) $arr[$f] = $this->_table->decrypt($arr[$f]); return parent::fromRow($arr); } /** * Delete existing record for this user_id, then insert this one * @return CcRecord provides fluent interface */ function replace() { if (empty($this->user_id) || $this->user_id <= 0) throw new Am_Exception_InternalError("this->user_id is empty in " . __METHOD__); $this->_table->deleteByUserId($this->user_id); return $this->insert(); } function getExpire($format = "%02d%02d") { if ("" == $this->cc_expire) return ""; $m = substr($this->cc_expire, 0, 2); $y = substr($this->cc_expire, 2, 2); return sprintf($format, $m, $y); } } class CcRecordTable extends Am_Table { protected $_crypt; protected $_key = 'cc_id'; protected $_table = '?_cc'; protected $_recordClass = 'CcRecord'; function encrypt($s){ return $this->_getCrypt()->encrypt($s); } function decrypt($s){ return $this->_getCrypt()->decrypt($s); } function _getCrypt(){ if (empty($this->_crypt)) $this->_crypt = Am_Di::getInstance ()->crypt; return $this->_crypt; } function setCrypt(Am_Crypt $crypt) { $this->_crypt = $crypt; } }