Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

update_geodist.php 728B

1234567891011121314151617181920
  1. <?
  2. $IPs = [];
  3. $DB->query("SELECT IP FROM users_main WHERE Enabled = '1'");
  4. while(list($EncIP) = $DB->next_record()) {
  5. $IPs[] = Crypto::decrypt($EncIP);
  6. }
  7. $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (IP VARCHAR(45) NOT NULL)");
  8. $DB->query("INSERT INTO users_ips_decrypted (IP) VALUES('".implode("'),('", $IPs)."')");
  9. $DB->query("TRUNCATE TABLE users_geodistribution");
  10. $DB->query("
  11. INSERT INTO users_geodistribution
  12. (Code, Users)
  13. SELECT g.Code, COUNT(u.IP) AS Users
  14. FROM geoip_country AS g
  15. JOIN users_ips_decrypted AS u ON INET_ATON(u.IP) BETWEEN g.StartIP AND g.EndIP
  16. GROUP BY g.Code
  17. ORDER BY Users DESC");
  18. $DB->query("DROP TABLE users_ips_decrypted");
  19. $Cache->delete_value('geodistribution');
  20. ?>