You are here

private function IP2Location::readBinary in Smart IP 6

Same name and namespace in other branches
  1. 7 includes/IP2Location.inc \IP2Location::readBinary()
1 call to IP2Location::readBinary()
IP2Location::readByte in includes/IP2Location.inc

File

includes/IP2Location.inc, line 244

Class

IP2Location

Code

private function readBinary($format, $data) {
  if ($this->unpack == self::BIG_ENDIAN) {
    $ar = unpack($format, $data);
    $vals = array_values($ar);
    $f = explode('/', $format);
    $i = 0;
    foreach ($f as $fKey => $fValue) {
      $repeater = intval(substr($fValue, 1));
      if ($repeater == 0) {
        $repeater = 1;
      }
      if ($fValue[1] == '*') {
        $repeater = count($ar) - $i;
      }
      if ($fValue[0] != 'd') {
        $i += $repeater;
      }
      continue;
      $j = $i + $repeater;
      for ($a = $i; $a < $j; ++$a) {
        $p = pack('d', $vals[$i]);
        $p = strrev($p);
        list($vals[$i]) = array_values(unpack('d1d', $p));
        ++$i;
      }
    }
    $a = 0;
    foreach ($ar as $arKey => $arValue) {
      $ar[$arKey] = $vals[$a];
      ++$a;
    }
    return $ar;
  }
  return unpack($format, $data);
}