| $a=time();$b=substr($a, 1);$orderid= $b.mt_rand(10000,99999);$mygoods['partner']="2088011744308664";$mygoods['seller']="zfb@sinoglobal.com.cn";$mygoods['out_trade_no']=$orderid;$mygoods['subject']=$goods_name;$mygoods['body']=$goods_infro;$mygoods['total_fee']=$score;$mygoods['notify_url']= "http://211.149.220.47/php/notify_url.php";$mygoods = argSort($mygoods);$mystr = createLinkstring($mygoods);$sign = rsaSign($mystr);$sign = urlencode($sign);$orderInfor = $mystr."&sign=".$sign."&sign_type=RSA"; function createLinkstring($para) { $arg = ""; while (list ($key, $val) = each ($para)) { $arg.=$key."=".$val."&"; } $arg = substr($arg,0,count($arg)-2); if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} return $arg;} function argSort($para) { ksort($para); reset($para); return $para;} function rsaSign($data, $private_key_path) { $priKey = file_get_contents($private_key_path); $res = openssl_get_privatekey($priKey); openssl_sign($data, $sign, $res); openssl_free_key($res); $sign = base64_encode($sign); return $sign;} |