Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. $url = '/var/www/ivt/nht_ips_current.gz';
  4.  
  5.  
  6. function uncompress($srcName) {
  7. $filesize=filesize('/var/www/ivt/nht_ips_current.gz');
  8. $newline = "\n";
  9.  
  10. $i=0;
  11.  
  12.  
  13. $sfp = gzopen($srcName, "rb");
  14.  
  15. while (!gzeof($sfp)) {
  16. $line = gzgets($sfp, 128);
  17.  
  18.  
  19. $data = explode("\t", $line);
  20. $i++;
  21.  
  22. $long = ip2long($data[0]);
  23. $sql[]='('.$long.')';
  24.  
  25.  
  26.  
  27. if($i==10000)
  28. {
  29. mysql_query('INSERT INTO alltheips VALUES '.implode(',', $sql));
  30. $i=0;
  31. unset($sql); // $foo is gone
  32. $sql = array();
  33.  
  34. }
  35.  
  36. }
  37. gzclose($sfp);
  38.  
  39. }
  40.  
  41.  
  42. uncompress($url);
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement