=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); } function decode_ip($int_ip) { return inet_ntop(hex2bin($int_ip)); } function encode_ip($ip=FALSE) { if(!$ip && !empty($_SERVER["HTTP_X_FORWARDED_FOR"])) $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; if(!$ip && !empty($_SERVER["HTTP_X_REAL_IP"])) $ip = $_SERVER["HTTP_X_REAL_IP"]; if(!$ip) $ip = $_SERVER['REMOTE_ADDR']; return bin2hex(inet_pton($ip)); } function url($string,$external=FALSE) { if($external) return htmlspecialchars($string); global $VAR; if(!empty($VAR['rewrite_url'])) { $masque = $VAR['rewrite_url']['masque']; $replace = $VAR['rewrite_url']['replace']; $var = preg_replace($masque,$replace,$string); return htmlspecialchars($var); } else return htmlspecialchars($string); } ?>