sorry for this mistak, i\'m working on SMDecoder class for entity file and this tow function have been made for this.Functions hexReverse and hexify are used by bin2Float.
function bin2Int($data){
if(strlen($data) != 32){
return -1;
} else {
if($data[0] == \"1\"){
$bin_replace = str_replace(\"1\",\"x\",$data);
$bin_replace = str_replace(\"0\",\"1\",$bin_replace);
$bin_replace = str_replace(\"x\",\"0\",$bin_replace);
if($bin_replace[31] === \"0\"){
$bin_replace[31] = 1;
}else{
$i=31;
$loop = true;
while($loop == true){
if($bin_replace[$i-1] == \"0\" && $i == 31){
$loop = false;
}else if($bin_replace[$i-1] == \"0\"){
$bin_replace[$i] = 0;
$bin_replace[$i-1] = 1;
$loop = false;
}
$i--;
}
}
return bindec($bin_replace) *-1;
}
else{
return bindec($data);
}
}
}
function bin2Float($data){
if(strlen($data) != 32){
return -1;
} else {
if($data === $null32){
return $nullFloat;
} else {
$hex = substr(chunk_split(base_convert($data, 2, 16), 2, \" \"), 0, -1);
$hexRev = hexReverse($hex);
$hexi = hexify($hexRev);
if($hexi === false) die(\"Invalid input\\n\");
$decode = unpack(\"f\", $hexi);
return $decode[1];
}
}
}
function hexReverse($hex){
$r = \'\';
$hexArray = explode(\' \', $hex);
foreach ($hexArray as $z) {
$r = $z . \' \' . $r;
}
return substr($r, 0, -1);
}
function hexify($hex){
static $hexVal = array(
\'0\'=>0, \'1\'=>1, \'2\'=>2, \'3\'=>3,
\'4\'=>4, \'5\'=>5, \'6\'=>6, \'7\'=>7,
\'8\'=>8, \'9\'=>9, \'A\'=>10, \'B\'=>11,
\'C\'=>12, \'D\'=>13, \'E\'=>14, \'F\'=>15,
\'a\'=>10, \'b\'=>11, \'c\'=>12, \'d\'=>13, \'e\'=>14, \'f\'=>15,
);
$r = \'\';
$hexArray = explode(\' \', $hex);
foreach ($hexArray as $z) {
if (!ctype_xdigit($z)) return false;
$tmp = $hexVal[$z{0}] * 16 + $hexVal[$z{1}];
$r .= chr($tmp);
}
return $r;
}
You\'ll need to replace function getServInfo() (i\'ve replaced functions used for convertion)