/** * getPlainSortAndByAnd方法 使用&符号组织签名明文串排序a-z,如:merId=9996&goodsId=100&version=3.0 * @param HashMap $map */ public static function getPlainSortAndByAnd($map) { $log = new Logger(); $plain = ""; $arg = ""; $paramter = array(); if (!$map->isEmpty() && $map->size() > 0) { $keys = $map->keys(); foreach ($keys as $key) { // $log->logInfo (" ssssssgetRequestData plain111122333=" . $keys ); //如果是sign_type 不许要参与RAS签名 if ("sign_type" != $key) { $plain = $plain . $key . "=" . $map->get($key) . "|"; //$paramter = explode ( "&", $plain ); $paramter[$key . "=" . $map->get($key)] = $key . "=" . $map->get($key); } } $plain = substr($plain, 0, strlen($plain) - 1); // $log->logInfo (" ssssssgetRequestData plain111122=" . $plain ); //$paramter = explode ( "|", $plain ); $sort_array = StringUtil::arg_sort($paramter); //得到从字母a到z排序后的加密参数数组 while (list($key, $val) = each($sort_array)) { $arg .= $val . "&"; //$log->logInfo (" ssssssgetRequestData plain11=" . $arg ); } $arg = substr($arg, 0, count($arg) - 2); //去掉最后一个&字符 //die ( "使用&组织签名明文串失败:传入参数为空!".$arg."|".plain ); return $arg; } else { die("Use & organize signature plaintext string failure: incoming parameters is empty!"); return null; } //$log->logInfo (" ssssssgetRequestData plain115=" . $arg ); return $arg; }
asort($c3); $cluster->remove($maxf1); $cluster->remove($maxf2); $cluster->put($maxf1, $c3); $len1 = pow(count($HFlist->get($flist[$maxf1])), 0.5) + 1.0E-8; $len2 = pow(count($HFlist->get($flist[$maxf2])), 0.5) + 1.0E-8; for ($i = 0; $i < $fnum; $i++) { $cosmatrix[$maxf1][$i] = ($len1 * $cosmatrix[$maxf1][$i] + $len2 * $cosmatrix[$maxf2][$i]) / ($len1 + $len2); $cosmatrix[$i][$maxf1] = $cosmatrix[$maxf1][$i]; } $I[$maxf2] = 0; } //end round for*/ echo "R:{$round}</br>"; echo "MAX:{$tempmax}</br>"; $cid = $cluster->keys(); // print_r ($cid); for ($i = 0; $i < count($cid); $i++) { $ca = $cluster->get($cid[$i]); echo "<div class=\"HOT\">"; for ($j = 0; $j < count($ca); $j++) { if ($j % 6 == 0) { echo "<div class=\"TOP\">"; } echo "<a href=\"" . $flinklist[$ca[$j]] . "\" target=\"_blank\" >" . $fnamelist[$ca[$j]] . "</a><img src=\"https://graph.facebook.com/" . $flist[$ca[$j]] . "/picture\">"; if ($j % 6 == 5) { echo "</br></div>"; } } if ($j % 6 != 0) { echo "</br></div>";
/** * V4.0对商户提交的参数进行校验,最终返回一个提交给平台的HashMap * @param HashMap $param 商户提交的参数 * @param HashMap $fields1 必填的参数 * @param HashMap $fields2 非必填参数 */ public static function getData($param, $fields1, $fields2) { //需要进行日期校验的参数 $field_date = new HashMap(); $field_date->put("settle_date", "settle_date"); $field_date->put("mer_date", "mer_date"); $field_date->put("payDate", "payDate"); //需要进行RAS加密的参数 $field_ras = new HashMap(); $field_ras->put("card_id", "card_id"); $field_ras->put("valid_date", "valid_date"); $field_ras->put("cvv2", "cvv2"); $field_ras->put("pass_wd", "pass_wd"); $field_ras->put("identity_code", "identity_code"); $field_ras->put("card_holder", "card_holder"); //付款请求添加RAS加密的参数 $field_ras->put("recv_account", "recv_account"); $field_ras->put("recv_user_name", "recv_user_name"); $field_ras->put("identity_holder", "identity_holder"); $data = new HashMap(); if (!$fields1->isEmpty() && $fields1->size() > 0) { $keys = $fields1->keys(); foreach ($keys as $key) { $value = StringUtil::trim($param->get($key)); $length = StringUtil::trim($fields1->get($key)); $flag = $field_date->containsKey($key); $flag1 = $field_ras->containsKey($key); if ($flag1) { if ("" == $value) { die($key . "为空或者长度超过限制"); } else { $value = iconv("UTF-8", "GBK", $value); $value = RSACryptUtil::encrypt($value); $data->put($key, $value); } } elseif ($flag) { if (!DateUtil::checkData($value)) { die($key . "为空或者长度不符合要求"); } else { $data->put($key, $value); } } elseif ("split_data" == $key) { if ("" == $value) { die($key . "为空或者长度超过限制"); } else { $data->put($key, $value); } } else { if ("" == $value || strlen($value) > $length) { die($key . "为空或者长度超过限制"); } else { $data->put($key, $value); } } } $keys1 = $fields2->keys(); foreach ($keys1 as $key) { if (!is_null($param->get($key))) { $value = StringUtil::trim($param->get($key)); $length = StringUtil::trim($fields2->get($key)); $flag1 = $field_ras->containsKey($key); if ($flag1) { if ("" != $value) { if (strlen($value) > $length) { die($key . "为空或者长度超过限制"); } else { $value = iconv("UTF-8", "GBK", $value); $value = RSACryptUtil::encrypt($value); $data->put($key, $value); } } } elseif ($field_date->containsKey($key)) { if (!DateUtil::checkData($value)) { die($key . "为空或者长度不符合要求"); } else { $data->put($key, $value); } } elseif ("split_data" == $key) { if ("" != $value) { $data->put($key, $value); } } else { if ("" != $value) { if (strlen($value) > $length) { die($key . "为空或者长度超过限制"); } else { $data->put($key, $value); } } } } } } else { die("获取请求参数字符串失败:传入参数为空!"); } return $data; }