test.php
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
function unpackage($queryString) {
$array = array();
parse_str($queryString, $array);
return $array;
}
$stringQuery = 'a1=4&A2=4';
$values = unpackage($stringQuery);
function package($values, $SecureHash, &$arrayRequestKey) {
$queryString = '';
//$hashData = $SecureHash;
// 1. The Secure Hash Secret is always first.
// 2. Then all DO fields are concatenated to the Secure Hash Secret in alphabetical order of the field name.
ksort($values);
foreach ($values as $key => $val) {
if (strlen($val) > 0) {
$queryString .= $key . '=' . rawurlencode($val) . '&';
//$hashData .= $val;
$arrayRequestKey[] = $key;
}
}
// Remove the trailing '&'.
$queryString = substr($queryString, 0, strlen($queryString) - 1);
// Create the secure hash and append it if the merchant secret has been provided.
if (strlen($SecureHash) > 0) {
$stringSecureHash = strtoupper(hash_hmac('SHA256', $queryString, pack('H*', $SecureHash)));
//strtoupper(md5($hashData))
$queryString = 'vpc_SecureHash=' . $stringSecureHash . '&vpc_SecureHashType=SHA256' . '&' . $queryString;
}
return $queryString;
}
$arrayRequestKey = array();
echo package($values, '123454567', $arrayRequestKey);
print_r($arrayRequestKey);
exit();
echo date('d-m-Y H:i:s');
exit();
echo dirname(__FILE__);
exit();
echo (extension_loaded('xdebug') ? '' : 'non '), 'exists';
ini_set('memory_limit', '256M');
phpinfo();
exit();
print_r($_SERVER);
echo dirname(__FILE__);
echo "Test trest";