3
function timestamp_to_soap_datetime($t) {
4
return date('Y-m-d\TH:i:sO',$t);
7
function soap_datetime_to_timestamp($t) {
8
/* Ignore Microsecconds */
9
$iso8601 = '(-?[0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]*)?(Z|[+\-][0-9]{4}|[+\-][0-9]{2}:[0-9]{2})?';
11
if (!ereg($iso8601,$t,$r)) {
14
$t = gmmktime($r[4],$r[5],$r[6],$r[2],$r[3],$r[1]);
15
if (!empty($r[8]) && $r[8] != 'Z') {
16
$op = substr($r[8],0,1);
17
$h = substr($r[8],1,2);
18
if (strstr($r[8],':')) {
19
$m = substr($r[8],4,2);
21
$m = substr($r[8],3,2);
23
$t += (($op == "-"?1:-1) * $h * 60 + $m) * 60;
29
function date_compare($f1,$f2)
31
return soap_datetime_to_timestamp($f1) == soap_datetime_to_timestamp($f2);
34
function hex_compare($f1, $f2)
36
return strcasecmp($f1,$f2) == 0;
39
function number_compare($f1, $f2)
41
# figure out which has the least fractional digits
42
preg_match('/.*?\.(.*)/',$f1,$m1);
43
preg_match('/.*?\.(.*)/',$f2,$m2);
45
# always use at least 2 digits of precision
46
$d = max(min(strlen(count($m1)?$m1[1]:'0'),strlen(count($m2)?$m2[1]:'0')),2);
50
// return bccomp($f1, $f2, $d) == 0;
53
function boolean_compare($f1, $f2)
55
if (($f1 == 'true' || $f1 === TRUE || $f1 != 0) &&
56
($f2 == 'true' || $f2 === TRUE || $f2 != 0)) return TRUE;
57
if (($f1 == 'false' || $f1 === FALSE || $f1 == 0) &&
58
($f2 == 'false' || $f2 === FALSE || $f2 == 0)) return TRUE;
62
function string_compare($e1, $e2)
64
if (is_numeric($e1) && is_numeric($e2)) {
65
return number_compare($e1, $e2);
67
# handle dateTime comparison
68
$e1_type = gettype($e1);
69
$e2_type = gettype($e2);
71
if ($e1_type == "string") {
72
// $dt = new SOAP_Type_dateTime();
73
// $ok = $dt->compare($e1, $e2) == 0;
76
return $ok || $e1 == $e2 || strcasecmp(trim($e1), trim($e2)) == 0;
79
function array_compare(&$ar1, &$ar2) {
80
if (gettype($ar1) != 'array' || gettype($ar2) != 'array') return FALSE;
81
if (count($ar1) != count($ar2)) return FALSE;
82
foreach ($ar1 as $k => $v) {
83
if (!array_key_exists($k,$ar2)) return FALSE;
84
if (!compare($v,$ar2[$k])) return FALSE;
89
function object_compare(&$obj1, &$obj2) {
90
if (gettype($obj1) != 'object' || gettype($obj2) != 'object') return FALSE;
91
// if (class_name(obj1) != class_name(obj2)) return FALSE;
94
return array_compare($ar1,$ar2);
97
function compare(&$x,&$y) {
99
$x_type = gettype($x);
100
$y_type = gettype($y);
101
if ($x_type == $y_type) {
102
if ($x_type == "array") {
103
$ok = array_compare($x, $y);
104
} else if ($x_type == "object") {
105
$ok = object_compare($x, $y);
106
} else if ($x_type == "double") {
107
$ok = number_compare($x, $y);
108
// } else if ($x_type == 'boolean') {
109
// $ok = boolean_compare($x, $y);
112
// $ok = string_compare($expect, $result);
119
function parseMessage($msg)
122
#$msg = preg_replace('/\r|\n/', ' ', $msg);
123
$response = new SOAP_Parser($msg);
124
if ($response->fault) {
125
return $response->fault->getFault();
127
$return = $response->getResponse();
128
$v = $response->decode($return);
129
if (gettype($v) == 'array' && count($v)==1) {
130
return array_shift($v);
135
function var_dump_str($var) {
138
$res = ob_get_contents();
b'\\ No newline at end of file'