function EncryptedPin($sPin, $sCardNo, $sPubKeyURL) { global $log; $sPubKeyURL = trim(SDK_ENCRYPT_CERT_PATH, " "); Think\Log::write("DisSpaces : " . PubKeyURL); $fp = fopen($sPubKeyURL, "r"); if ($fp != NULL) { $sCrt = fread($fp, 8192); // $log->LogInfo("fread PubKeyURL : " . $sCrt); fclose($fp); } $sPubCrt = openssl_x509_read($sCrt); if ($sPubCrt === FALSE) { print "openssl_x509_read in false!"; return -1; } Think\Log::write($sPubCrt); // $sPubKeyId = openssl_x509_parse($sCrt); Think\Log::write($sPubKeyId); $sPubKey = openssl_x509_parse($sPubCrt); Think\Log::write($sPubKey); // openssl_x509_free($sPubCrt); // print_r(openssl_get_publickey($sCrt)); $sInput = Pin2PinBlockWithCardNO($sPin, $sCardNo); if ($sInput == 1) { print "Pin2PinBlockWithCardNO Error ! : " . $sInput; return 1; } $iRet = openssl_public_encrypt($sInput, $sOutData, $sCrt, OPENSSL_PKCS1_PADDING); if ($iRet === TRUE) { // $log->LogInfo($sOutData); $sBase64EncodeOutData = base64_encode($sOutData); //print("PayerPin : " . $sBase64EncodeOutData); return $sBase64EncodeOutData; } else { print "openssl_public_encrypt Error !"; return -1; } }
/** * 如果操作失败则记录日志 * @return array 格式:array('status'=>boolean,'info'=>'错误信息') * @author hebiduhebi@163.com */ function ifFailedLogRecord($result, $location) { if ($result['status'] === false) { Think\Log::write($location . $result['info'], 'ERR'); } }
/** * 处理报文中的文件 * * @param unknown_type $params */ function deal_file($params) { global $log; if (isset($params['fileContent'])) { Think\Log::write("---------处理后台报文返回的文件---------"); $fileContent = $params['fileContent']; if (empty($fileContent)) { Think\Log::write('文件内容为空'); } else { // 文件内容 解压缩 $content = gzuncompress(base64_decode($fileContent)); $root = SDK_FILE_DOWN_PATH; $filePath = null; if (empty($params['fileName'])) { Think\Log::write("文件名为空"); $filePath = $root . $params['merId'] . '_' . $params['batchNo'] . '_' . $params['txnTime'] . '.txt'; } else { $filePath = $root . $params['fileName']; } $handle = fopen($filePath, "w+"); if (!is_writable($filePath)) { Think\Log::write("文件:" . $filePath . "不可写,请检查!"); } else { file_put_contents($filePath, $content); Think\Log::write("文件位置 >:" . $filePath); } fclose($handle); } } }
public function callback() { include_once APP_PATH . '/BaoyiPay/BaoyiPay.php'; $xml = $_POST['data']; $info = xml2arr($xml); $body = $info['body']; //返回成功 if ($body['state'] == '02') { // 结算成功 Think\Log::write('业务号:(' . $body['tranSeqId'] . ')处理成功(02)'); $pay = M('DrawcashList')->where(array('bussflowno' => $body['tranSeqId']))->find(); if ($pay['status'] == 0) { //更新提现记录 $drawcashlist = array('id' => $pay['id'], 'real_amount' => $body['amount'], 'submitdate' => $body['submitDate'], 'acctno' => $body['acctNo'], 'acctname' => $body['acctName'], 'state' => $body['state'], 'proctime' => $body['procTime'], 'remark' => $body['remark'], 'update_time' => NOW_TIME, 'status' => '1'); M('CashFlow')->where(array('bussflowno' => $body['tranSeqId']))->save(array('state' => 1)); M('DrawcashList')->save($drawcashlist); } } elseif ($body['state'] == '03') { // 结算失败 Think\Log::write('业务号:(' . $body['tranSeqId'] . ')结算失败(03)'); //查看交易记录 $pay = M('DrawcashList')->where(array('bussflowno' => $body['tranSeqId']))->find(); if ($pay['status'] == 0) { //更新提现金额 $productinfo = M('Product')->find($pay['pid']); $drawcash_amount = $productinfo['drawcash_amount'] - $body['amount']; $product = array('id' => $pay['pid'], 'drawcash_amount' => $drawcash_amount); M('Product')->save($product); //更新提现记录 $drawcashlist = array('id' => $pay['id'], 'real_amount' => $body['amount'], 'submitdate' => $body['submitDate'], 'acctno' => $body['acctNo'], 'acctname' => $body['acctName'], 'state' => $body['state'], 'proctime' => $body['procTime'], 'remark' => $body['remark'], 'update_time' => NOW_TIME, 'status' => '2'); M('DrawcashList')->save($drawcashlist); } } else { if ($body['state'] == '00') { Think\Log::write('业务号:(' . $body['tranSeqId'] . ')待结算(00)'); } else { if ($body['state'] == '01') { Think\Log::write('业务号:(' . $body['tranSeqId'] . ')处理中(01)'); } else { if ($body['state'] == '04') { Think\Log::write('业务号:(' . $body['tranSeqId'] . ')处理中'); } } } } }
/** * 重新整理listFields数据,将原始的listFields转换为运行时状态。比如:valChange的转换。 * fdn 字符串转化成了 中文字段 * $original 保持原型 true * **/ public function getListFields($reNew = false, $original = false) { //dump('ssss');die; $Log = new \Think\Log(); $Log->write($this->name . "->getListFields", 'INFO'); //Log::write($this->name."->getListFields",LOG::INFO); if ($original) { return $this->listFields; } // 使用listFields的md5值,作为缓存名,形成唯一缓存,一点list改变,则缓存自动失效,随意无需renew // if($reNew || C("APP_DEBUG")){ // $this->setCacheListFields(); // return $this->cacheListFields; // } //dump($this->cacheListFields);exit; if (empty($this->cacheListFields)) { $cacheFile = '_fields/' . $this->name . "_listFields_" . $this->getListFieldsMd5(); //dump($cacheFile);exit; $this->cacheListFields = F($cacheFile); // dump($this->cacheListFields);die; if (empty($this->cacheListFields)) { //die('ddee'); $this->setCacheListFields($cacheFile); } } return $this->cacheListFields; }
/** * 根据证书ID 加载 证书 * * @param unknown_type $certId * @return string NULL */ function getPulbicKeyByCertId($certId) { global $log; Think\Log::write('报文返回的证书ID>' . $certId); // 证书目录 $cert_dir = SDK_VERIFY_CERT_DIR; Think\Log::write('验证签名证书目录 :>' . $cert_dir); $handle = opendir($cert_dir); if ($handle) { while ($file = readdir($handle)) { clearstatcache(); $filePath = $cert_dir . '/' . $file; if (is_file($filePath)) { if (pathinfo($file, PATHINFO_EXTENSION) == 'cer') { if (getCertIdByCerPath($filePath) == $certId) { closedir($handle); Think\Log::write('加载验签证书成功'); return getPublicKey($filePath); } } } } Think\Log::write('没有找到证书ID为[' . $certId . ']的证书'); } else { Think\Log::write('证书目录 ' . $cert_dir . '不正确'); } closedir($handle); return null; }