/** * 易宝支付-公共函数 * * 易宝支付-公共函数 ( http://www.yeepay.com) * * 调用模板:无 * * @category jieqicms * @package pay * @copyright Copyright (c) Hangzhou Jieqi Network Technology Co.,Ltd. (http://www.jieqi.com) * @author $Author: juny $ * @version $Id: yeepaycommon.php 300 2008-12-26 04:36:06Z juny $ */ function hmac($key, $data) { // RFC 2104 HMAC implementation for php. // Creates an md5 HMAC. // Eliminates the need to install mhash to compute a HMAC // Hacked by Lance Rushing(NOTE: Hacked means written) //需要配置环境支持iconv,否则中文参数不能正常处理 if (function_exists('iconv')) { $key = iconv("GB2312", "UTF-8", $key); $data = iconv("GB2312", "UTF-8", $data); } else { include_once JIEQI_ROOT_PATH . '/include/changecode.php'; $key = jieqi_gb2utf8($key); $data = jieqi_gb2utf8($data); } $b = 64; // byte length for md5 if (strlen($key) > $b) { $key = pack("H*", md5($key)); } $key = str_pad($key, $b, chr(0x0)); $ipad = str_pad('', $b, chr(0x36)); $opad = str_pad('', $b, chr(0x5c)); $k_ipad = $key ^ $ipad; $k_opad = $key ^ $opad; return md5($k_opad . pack("H*", md5($k_ipad . $data))); }
function txt2utf8($txt, $codepage = "gb2312") { if (function_exists("iconv")) { return iconv($codepage, "UTF-8", $txt); } else { include_once JIEQI_ROOT_PATH . '/include/changecode.php'; if (strtolower($codepage) == "gb2312" || strtolower($codepage) == "gbk") { return jieqi_gb2utf8($txt); } elseif (strtolower($codepage) == "big5") { return jieqi_big52utf8($txt); } else { return $txt; } } }
$MSGCONTENT = str_replace(array('<{$egold}>', '<{$serialno}>', '<{$randpass}>'), array($egold, $serialno, $randstr), $message); $MSGCONTENT = base64_encode($MSGCONTENT); $MSGLEN = strlen($MSGCONTENT); //已经记录交易,发回信息 $nowtime = date('YmdHi', time()); $SENDTIME = $nowtime; $DESTTERMID = $SRCTERMID; $FEETERMID = $SRCTERMID; $SRCTERMID = $SRCTERMID; $returl = $jieqiPayset[JIEQI_PAY_TYPE]['payurl']; $retdata = '<?xml version="1.0" encoding="utf-8"?><ROOT><USER>' . $USER . '</USER><PASS>' . $PASS . '</PASS><MT><MOID>' . $MOID . '</MOID><MSGCONTENT>' . $MSGCONTENT . '</MSGCONTENT><MSGLEN>' . $MSGLEN . '</MSGLEN><SRCTERMID>' . $SRCTERMID . '</SRCTERMID><DESTTERMID>' . $DESTTERMID . '</DESTTERMID><SERVICEID>' . $SERVICEID . '</SERVICEID><FEETERMID>' . $FEETERMID . '</FEETERMID><MSGFORMAT>' . $MSGFORMAT . '</MSGFORMAT><MOUSEID>' . $MOUSEID . '</MOUSEID><MOUSEPACKAGEID>' . $MOUSEPACKAGEID . '</MOUSEPACKAGEID><CITYID>' . $CITYID . '</CITYID><PROVINCEID>' . $PROVINCEID . '</PROVINCEID><GATEWAYID>' . $GATEWAYID . '</GATEWAYID><CLASSID>' . $CLASSID . '</CLASSID><SMTYPEID>' . $SMTYPEID . '</SMTYPEID><ISIMBALANCE>' . $ISIMBALANCE . '</ISIMBALANCE><ATTIME>' . $ATTIME . '</ATTIME><SENDTIME>' . $SENDTIME . '</SENDTIME><MTTYPE>' . $MTTYPE . '</MTTYPE><SPNUMBER>' . $SPNUMBER . '</SPNUMBER><LINKID>' . $LINKID . '</LINKID><REMARK>' . $REMARK . '</REMARK></MT></ROOT>'; if ($logflag) { jieqi_writefile(JIEQI_ROOT_PATH . '/cache/tomorrowsend.txt', $retdata, 'ab'); } include_once JIEQI_ROOT_PATH . '/include/changecode.php'; $retdata = jieqi_gb2utf8($retdata); $ret = posttohost($returl, $retdata); if ($logflag) { jieqi_writefile(JIEQI_ROOT_PATH . '/cache/tomorrowret.txt', $ret, 'ab'); } function xml_getvaluebytag($source = '', $tag = '') { $ret = ''; if (!empty($tag)) { $pregstr = '/' . jieqi_pregconvert('<' . $tag . '>') . '([^\\<\\>]*)' . jieqi_pregconvert('</' . $tag . '>') . '/is'; $matches = array(); preg_match($pregstr, $source, $matches); if (is_array($matches) && count($matches) > 0) { $ret = $matches[count($matches) - 1]; } }