$val ) { if ($key == 'signature') { continue; } $sign_str .= sprintf ( "%s=%s&", $key, $val ); } return substr ( $sign_str, 0, strlen ( $sign_str ) - 1 ); } function coverStringToArray($str) { $result = array (); if (! empty ( $str )) { $temp = preg_split ( '/&/', $str ); if (! empty ( $temp )) { foreach ( $temp as $key => $val ) { $arr = preg_split ( '/=/', $val, 2 ); if (! empty ( $arr )) { $k = $arr ['0']; $v = $arr ['1']; $result [$k] = $v; } } } } return $result; } function deal_params(&$params) { if (! empty ( $params ['customerInfo'] )) { $params ['customerInfo'] = base64_decode ( $params ['customerInfo'] ); } if (! empty ( $params ['encoding'] ) && strtoupper ( $params ['encoding'] ) == 'utf-8') { foreach ( $params as $key => $val ) { $params [$key] = iconv ( 'utf-8', 'UTF-8', $val ); } } } function deflate_file(&$params) { global $log; foreach ( $_FILES as $file ) { $log->LogInfo ( "---------处理文件---------" ); if (file_exists ( $file ['tmp_name'] )) { $params ['fileName'] = $file ['name']; $file_content = file_get_contents ( $file ['tmp_name'] ); $file_content_deflate = gzcompress ( $file_content ); $params ['fileContent'] = base64_encode ( $file_content_deflate ); $log->LogInfo ( "压缩后文件内容为>" . base64_encode ( $file_content_deflate ) ); } else { $log->LogInfo ( ">>>>文件上传失败<<<<<" ); } } } function deal_file($params) { global $log; if (isset ( $params ['fileContent'] )) { $log->LogInfo ( "---------处理后台报文返回的文件---------" ); $fileContent = $params ['fileContent']; if (empty ( $fileContent )) { $log->LogInfo ( '文件内容为空' ); } else { $content = gzuncompress ( base64_decode ( $fileContent ) ); $root = SDK_FILE_DOWN_PATH; $filePath = null; if (empty ( $params ['fileName'] )) { $log->LogInfo ( "文件名为空" ); $filePath = $root . $params ['merId'] . '_' . $params ['batchNo'] . '_' . $params ['txnTime'] . 'txt'; } else { $filePath = $root . $params ['fileName']; } $handle = fopen ( $filePath, "w+" ); if (! is_writable ( $filePath )) { $log->LogInfo ( "文件:" . $filePath . "不可写,请检查!" ); } else { file_put_contents ( $filePath, $content ); $log->LogInfo ( "文件位置 >:" . $filePath ); } fclose ( $handle ); } } } function create_html($params, $action) { $encodeType = isset ( $params ['encoding'] ) ? $params ['encoding'] : 'UTF-8'; $html = <<
eot; foreach ( $params as $key => $value ) { $html .= " \n"; } $html .= << eot; return $html; } ?>