Changeset View
Changeset View
Standalone View
Standalone View
src/utils/utils.php
Show First 20 Lines • Show All 1,531 Lines • ▼ Show 20 Lines | function phutil_hashes_are_identical($u, $v) { | ||||
$bits = 0; | $bits = 0; | ||||
for ($ii = 0; $ii < $len; $ii++) { | for ($ii = 0; $ii < $len; $ii++) { | ||||
$bits |= (ord($u[$ii]) ^ ord($v[$ii])); | $bits |= (ord($u[$ii]) ^ ord($v[$ii])); | ||||
} | } | ||||
return ($bits === 0); | return ($bits === 0); | ||||
} | } | ||||
/** | |||||
* Build a query string from a dictionary. | |||||
* | |||||
* @param map<string, string> Dictionary of parameters. | |||||
* @return string HTTP query string. | |||||
*/ | |||||
function phutil_build_http_querystring(array $parameters) { | |||||
// We want to encode in RFC3986 mode, but "http_build_query()" did not get | |||||
// a flag for that mode until PHP 5.4.0. This is equivalent to calling | |||||
// "http_build_query()" with the "PHP_QUERY_RFC3986" flag. | |||||
$query = array(); | |||||
foreach ($parameters as $key => $value) { | |||||
$query[] = rawurlencode($key).'='.rawurlencode($value); | |||||
} | |||||
$query = implode($query, '&'); | |||||
return $query; | |||||
} |