userbyip.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. if (ubRouting::get('action') == 'userbyip') {
  3. if (@$alterconf['USERBYIP_ENABLED']) {
  4. if (ubRouting::checkGet('ip')) {
  5. $ip = ubRouting::get('ip', 'mres');
  6. $guessedLogin = zb_UserGetLoginByIp($ip);
  7. $result = array('result' => 0);
  8. if (!empty($guessedLogin)) {
  9. $allUserData = zb_UserGetAllDataCache();
  10. if (isset($allUserData[$guessedLogin])) {
  11. $result['result'] = 1;
  12. $result['userdata'] = $allUserData[$guessedLogin];
  13. if ($alterconf['OPENPAYZ_SUPPORT']) {
  14. $openPayz = new OpenPayz(false, false);
  15. $result['userdata']['paymentid'] = $openPayz->getCustomerPaymentId($guessedLogin);
  16. }
  17. }
  18. }
  19. header('Last-Modified: ' . gmdate('r'));
  20. header('Content-Type: application/json; charset=UTF-8');
  21. header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
  22. header("Pragma: no-cache");
  23. header('Access-Control-Allow-Origin: *');
  24. print(json_encode($result));
  25. die();
  26. } else {
  27. die('ERROR: EMPTY IP');
  28. }
  29. } else {
  30. die('ERROR: USERBYIP DISABLED');
  31. }
  32. }