Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/10/2012, 10:30
azaz
 
Fecha de Ingreso: enero-2011
Mensajes: 1.150
Antigüedad: 13 años, 3 meses
Puntos: 10
geoLiteCity me da error en una funcion

Hola estoy intentando usar la clase geoLiteCity pero me da error en una funcion exactamente esta funcion:

Código PHP:
Ver original
  1. function _geoip_seek_country($gi, $ipnum) {
  2.   $offset = 0;
  3.   for ($depth = 31; $depth >= 0; --$depth) {
  4.     if ($gi->flags & GEOIP_MEMORY_CACHE) {
  5.       // workaround php's broken substr, strpos, etc handling with
  6.       // mbstring.func_overload and mbstring.internal_encoding
  7.       $enc = mb_internal_encoding();
  8.        mb_internal_encoding('ISO-8859-1');
  9.  
  10.       $buf = substr($gi->memory_buffer,
  11.                             2 * $gi->record_length * $offset,
  12.                             2 * $gi->record_length);
  13.  
  14.       mb_internal_encoding($enc);
  15.     } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
  16.       $buf = @shmop_read ($gi->shmid,
  17.                             2 * $gi->record_length * $offset,
  18.                             2 * $gi->record_length );
  19.         } else {
  20.       fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
  21.         or die("fseek failed");
  22.       $buf = fread($gi->filehandle, 2 * $gi->record_length);
  23.     }
  24.     $x = array(0,0);
  25.     for ($i = 0; $i < 2; ++$i) {
  26.       for ($j = 0; $j < $gi->record_length; ++$j) {
  27.         $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
  28.       }
  29.     }
  30.     if ($ipnum & (1 << $depth)) {
  31.       if ($x[1] >= $gi->databaseSegments) {
  32.         return $x[1];
  33.       }
  34.       $offset = $x[1];
  35.         } else {
  36.       if ($x[0] >= $gi->databaseSegments) {
  37.         return $x[0];
  38.       }
  39.       $offset = $x[0];
  40.     }
  41.   }
  42.   trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
  43.   return false;
  44. }

el error que me da es este:

Notice: Uninitialized string offset: 0

exactamente la linea del error es esta:
Código PHP:
Ver original
  1. $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);