function verMoney($money)
{
$preg = '/^([1-9]\d{0,7}|0)(\.\d{1,2})?$/';
$result = preg_match($preg, $money);
return $result;
}
function verInteger($num)
{
$preg = '/^[1-9][0-9]*$/';
$result = preg_match($preg, $num);
return $result;
}
function makeSign($data, $appSecret)
{
ksort($data);
$str = '';
foreach ($data as $k => $v) {
if (!empty($v)) {
$str .= '&' . $k . '=' . $v;
}
}
$str = trim($str, '&');
$sign = strtoupper(md5($str . '&key=' . $appSecret));
return $sign;
}
function httpRequest($url, $method = 'GET', $postData = [], $headers = [])
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (stripos($url, 'https') === 0) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
if (!$data) {
return false;
}
curl_close($ch);
return $data;
}