Fix for PHP 7.2 compatibility

This commit is contained in:
nemunaire 2020-11-15 17:20:47 +01:00 committed by Nigel Sheldon
parent 1e8c022806
commit 7df8c34fc5
1 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ function bithex($var)
}
function cxor($msg,$cle)
{
{
$xor = NULL;
for($i = 0; $i < strlen($msg);$i++) $xor .= substr($msg,$i,1) ^ substr($cle,$i % strlen($cle),1);
return $xor;
@ -45,19 +45,19 @@ function uniquehash($var,$length=128,$raw=FALSE)
{
$hashs = array('tiger192,4','haval256,5','md5','snefru','gost','ripemd160','whirlpool');
$r = hash('sha512',$var,TRUE);
foreach($hashs as $algo) $r = cxor(strrev($r),hash($algo,strrev($r),TRUE));
if($length % 8 == 0 && $length >=128 && $length <= 512) $r = substr($r,0,$length/8);
if(!$raw) $r = strhex($r);
return $r;
}
function temphash($var,$length=128,$raw=FALSE)
{
if(!$val = Cache::read('_temphash')) Cache::set('_temphash',$val = hexstr(random()));
return uniquehash(cxor($var,$val),$length,$raw);
}
@ -70,7 +70,7 @@ function decode_ip($int_ip)
function encode_ip($dotquad_ip=FALSE)
{
if(!$dotquad_ip) $dotquad_ip = $_SERVER['REMOTE_ADDR'];
$ip_sep = explode('.', $dotquad_ip);
if (empty($ip_sep[3])) $ip_sep = explode('.', "127.0.0.1");
return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
@ -79,9 +79,9 @@ function encode_ip($dotquad_ip=FALSE)
function url($string,$external=FALSE)
{
if($external) return htmlspecialchars($string);
global $VAR;
if(!empty($VAR['rewrite_url']))
{
$masque = $VAR['rewrite_url']['masque'];
@ -91,4 +91,4 @@ function url($string,$external=FALSE)
}
else return htmlspecialchars($string);
}
?>
?>