[ Príspevkov: 2 ] 
AutorSpráva
Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 31.07.07
Prihlásený: 09.01.19
Príspevky: 327
Témy: 85 | 85
Bydlisko: Humenné
NapísalOffline : 07.04.2009 14:04 | Problém s GEOIP

Ahojte mam dosť zavažny problem mam GEOIP skript a ono mi to v FTP vytvara súbory core s 30 MB veľkosťou a nevytvori ho len 1 ale aj 100-ky mam skript geoip.php , súbor GeoIPCountryWhois.gz kde je zoznam všetkych krajín a IP-čiek a ešte mam súbor geoip.xml zaujimalo by ma prečo mi na hostingu vytvara súbory core

geoip.php

Kód:
<?php

class GeoIP
{
   var $_path;


   /**
   * Boolean found
   *
   * @since 1.0
   * @var boolean
   */
   var $_found         = false;

   /**
   * Starting address of the class
   *
   * @return void
   * @var boolean
   */
   var $_start_ip       = false;

   /**
   * Ending address of the class
   *
   * @return void
   * @var boolean
   */
   var $_end_ip       = false;

   /**
   * Country code
   *
   * @return void
   * @var boolean
   */
   var $_country_code    = false;

   /**
   * Country name
   *
   * @return void
   * @var boolean
   */
   var $_country_name    = false;

   /**
   * CSV values
   *
   * @return void
   * @var boolean
   */
   var $_data         = array();

   /**
   * Long representation of the IP
   *
   * @return void
   * @var boolean
   */
   var $_longip      = 0;

   /**
   * Class constructor
   *
   * @return void
   * @access public
   * @static
   * @since 1.0
   */
   function GeoIP()
   {
      $filename = "GeoIPCountryWhois.gz";
      $this->_data = gzfile($filename);
   }

   /**
   * IP address conversion: A.B.C.D -> log
   *
   * @param string $string IP Address: A.B.C.D
   * @return long
   * @access private
   * @static
   * @since 1.0
   */
    function convert2number($string)
   {
      $pattern= "\"([0-9]+)\"";
      if (ereg($pattern, $string, $regs))
         return (int)$regs[1];
   }

   /**
   * IP searching
   *
   * @param string $beg Starting index
   * @param string $end Ending index
   * @return long/bool
   * @access private
   * @static
   * @since 1.0
   */
    function search($beg, $end)
   {
      /**
      This is the main search functions.

      It uses the DIVIDE-ET-IMPERA paradigm to find the specified IP in the data array.
      Each data in the array looks like:
         "IP_1","IP_2","LONG_IP_1","LONG_IP_2","COUNTRY_CODE","COUNTRY_NAME"

      IP is belonging to COUNTRY_NAME if complies with the formula:
         LONG_IP_1 <= LONG_IP <= LONG_IP_2

      The function returns either:
         - the pozition in the array IF FOUND
         - false, IF NOT FOUND
      */

      $mid = ceil(($end + $beg) / 2);


      $arr_beg = array();
      $arr_mid = array();
      $arr_end = array();

      $arr_beg = explode(",", $this->_data[$beg]);
      $arr_mid = explode(",", $this->_data[$mid]);
      $arr_end = explode(",", $this->_data[$end]);


      $arr_beg[2] = str_replace('"', '', $arr_beg[2]);
      $arr_beg[3] = str_replace('"', '', $arr_beg[3]);

      $arr_mid[2] = str_replace('"', '', $arr_mid[2]);
      $arr_mid[3] = str_replace('"', '', $arr_mid[3]);

      $arr_end[2] = str_replace('"', '', $arr_end[2]);
      $arr_end[3] = str_replace('"', '', $arr_end[3]);




      if (($this->_longip >= $arr_beg[2]) && ($this->_longip <= $arr_beg[3]))
      {
         unset($arr_beg); unset($arr_mid); unset($arr_end);
         return $beg;
      }
      else
         if (($this->_longip >= $arr_mid[2]) && ($this->_longip <= $arr_mid[3]))
         {
            unset($arr_beg); unset($arr_mid); unset($arr_end);
            return $mid;
         }
         else
            if (($this->_longip >= $arr_end[2]) && ($this->_longip <= $arr_end[3]))
            {
               unset($arr_beg); unset($arr_mid); unset($arr_end);
               return $end;

            }
            else
               if (($this->_longip > $arr_beg[3]) && ($this->_longip < $arr_mid[2]))
               {
                  unset($arr_beg); unset($arr_mid); unset($arr_end);
                  return $this->search($beg, $mid);
               }
               else
                  if (($this->_longip > $arr_mid[3]) && ($this->_longip < $arr_end[2]))
                  {
                     unset($arr_beg); unset($arr_mid); unset($arr_end);
                     return $this->search($mid, $end);
                  }
                  else
                  {
                     unset($arr_beg); unset($arr_mid); unset($arr_end);
                     return false;
                  }
   }


   /**
   * IP conversion
   *
   * @param string $address IP address in the A.B.C.D format
   * @return long
   * @access private
   * @static
   * @since 1.0
   */
   function IpAddress2IpNumber($address)
   {
      $pattern = "([0-9]+).([0-9]+).([0-9]+).([0-9]+)";

      if (ereg($pattern, $address, $regs))
         return $number = $regs[1] * 256 * 256 * 256 + $regs[2] * 256 * 256 + $regs[3] * 256 + $regs[4];
      else
         return false;
   }


   /**
   * MAIN SEARCH
   *
   * @param string $ip The IP Searched
   * @return void
   * @access private
   * @static
   * @since 1.0
   */
   function search_ip($ip)
   {
      // if not localhost ...
      if (($ip != "127.0.0.1") && ($ip != "0.0.0.1"))
      {
         $this->_longip = $this->IpAddress2IpNumber($ip);

         if ($this->_longip !== false)
            $poz = $this->search(0, sizeof($this->_data)-1);

         if ($poz !== false)
         {
            $info = explode(",", $this->_data[$poz]);

            $this->_found         = true;
            $this->_start_ip       = str_replace('"', '', $info[0]);
            $this->_end_ip          = str_replace('"', '', $info[1]);
            $this->_country_code    = str_replace('"', '', $info[4]);
            $this->_country_name    = str_replace('"', '', $info[5]);
         }
      }
   }

   /**
   * IP Class start
   *
   * @return string
   * @access public
   * @static
   * @since 1.0
   */
   function getStartIp()      {return $this->_start_ip;}

   /**
   * IP Class end
   *
   * @return string
   * @access public
   * @static
   * @since 1.0
   */
   function getEndIp()         {return $this->_end_ip;}

   /**
   * IP Country Code
   *
   * @return string
   * @access public
   * @static
   * @since 1.0
   */

   function getCountryCode()   {return $this->_country_code;}

   /**
   * IP Country name
   *
   * @return string
   * @access public
   * @static
   * @since 1.0
   */
    function getCountryName()   {return $this->_country_name;}

   /**
   * IP Found flag
   *
   * @return boolean
   * @access public
   * @static
   * @since 1.0
   */
    function found()            {return $this->_found;}


   /**
   * Class unset
   *
   * @return void
   * @access public
   * @static
   * @since 1.0
   */
    function destroy()
   {
      unset($this->_found);
      unset($this->_start_ip);
      unset($this->_end_ip);
      unset($this->_country_code);
      unset($this->_country_name);
      unset($this->_data);
      unset($this);
   }
}


?>


geoip.xml
Kód:
<?xml version="1.0" ?>

<package version="1.0">
   <name>GeoIPWhois Localization</name>
   <summary>This class implements country localization using the IP</summary>
   <description>Using the remote's host IP, this class locates the country usign the CSV WhoisIP file</description>
   <license>LGPL</license>
   <maintainers>
      <user>Marius Zadara</user>
      <role>developer</role>
      <name>Marius Zadara</name>
      <email>marius_victor@yahoo.com</email>
   </maintainers>
   <releaase>
      <version>1.0</version>
      <state>stable</state>
      <date>12th December 2006</date>
      <license>LGPL</license>
      <notes>Final optimized version</notes>
      <filelist>
         <file name="geoip.php" role="php" />
         <file name="GeoIPCountryWhois.csv" role="data" />
      </filelist>
   </release>
</package>


Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 31.07.07
Prihlásený: 09.01.19
Príspevky: 327
Témy: 85 | 85
Bydlisko: Humenné
Napísal autor témyOffline : 08.04.2009 13:31 | Problém s GEOIP

Vyriešenie sťahol som z netu iny skript a upravil podľa svojich predstáv


 [ Príspevkov: 2 ] 


Problém s GEOIP



Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy.

M Firefox problém so sťahovaním a GCH problém s updatom

v Sieťové a internetové programy

0

1620

23.01.2015 16:06

Stary

V tomto fóre nie sú ďalšie neprečítané témy.

Problém s AMD Adrenaline alebo je to softvér či HW problém?

v ATI/AMD grafické karty

3

130

20.02.2025 16:22

tairikuokami

V tomto fóre nie sú ďalšie neprečítané témy.

Problém so zobrazovaním www stránok, problém užívateľa

v Operačné systémy Microsoft

17

2379

23.03.2009 10:41

FERDA23

Táto téma je zamknutá, nemôžete posielať nové príspevky alebo odpovedať na staršie.

Battlefield 3 SKIDROW problem + win7 problem

v Počítačové hry

1

1848

22.09.2012 23:51

walther

V tomto fóre nie sú ďalšie neprečítané témy.

Záhadný problém s PC... problém procesora?

[ Choď na stránku:Choď na stránku: 1, 2 ]

v AMD - Advanced Micro Devices

45

5224

26.04.2012 11:14

netpeter77

V tomto fóre nie sú ďalšie neprečítané témy.

Problém s MB ASUS P5K - problém s Realtek

v Ovládače

4

2663

14.06.2008 10:36

$ph!nX

V tomto fóre nie sú ďalšie neprečítané témy.

Problém s HDD / Problém s bootovaním

v Pevné disky a radiče

4

1704

22.02.2013 14:08

lucifer666x

V tomto fóre nie sú ďalšie neprečítané témy.

problem

v Operačné systémy Unix a Linux

2

677

28.12.2008 11:49

branislav.poldauf

V tomto fóre nie sú ďalšie neprečítané témy.

problem

v Operačné systémy Microsoft

2

834

09.08.2007 22:29

shiro

V tomto fóre nie sú ďalšie neprečítané témy.

Problem

v Intel čipové sady

13

536

03.12.2011 17:28

sido007

V tomto fóre nie sú ďalšie neprečítané témy.

problem

v Pevné disky a radiče

7

673

22.09.2009 17:28

Milan.H

V tomto fóre nie sú ďalšie neprečítané témy.

Problém?

v Ostatné grafické karty

10

1232

22.09.2009 12:37

mr_HANN

V tomto fóre nie sú ďalšie neprečítané témy.

problém

v Webhosting a servery

2

1111

17.08.2009 17:51

scrysurn

V tomto fóre nie sú ďalšie neprečítané témy.

problem

v nVidia grafické karty

1

918

05.03.2007 21:40

Shark NX

V tomto fóre nie sú ďalšie neprečítané témy.

problem

v Assembler, C, C++, Pascal, Java

2

364

06.10.2012 18:21

kustom456

V tomto fóre nie sú ďalšie neprečítané témy.

problem

v Notebooky a netbooky

6

308

18.12.2013 21:50

screw



© 2005 - 2025 PCforum, edited by JanoF