Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v7 RC] Discord location flag empty (XX) #213

Open
UG-Asger opened this issue Aug 13, 2024 · 2 comments
Open

[v7 RC] Discord location flag empty (XX) #213

UG-Asger opened this issue Aug 13, 2024 · 2 comments

Comments

@UG-Asger
Copy link

Maybe add some international icon so it does not show a "white" square

image

tltneon added a commit that referenced this issue Aug 21, 2024
@UG-Asger
Copy link
Author

UG-Asger commented Aug 27, 2024

Maybe just use discord icon with transparent background. Looks better ;)
image
And if possible maybe convert XX to DS for discord

@Sh4d0wless
Copy link

i maked lil changes in lgsl_class, works perfectly...

static function locationCode(string $ip): string {
      global $lgsl_config;
      if ($lgsl_config['locations'] !== 1 && $lgsl_config['locations'] !== true) { return $lgsl_config['locations']; }
      $ip = gethostbyname($ip);
      if (long2ip(ip2long($ip)) == "255.255.255.255") { return "XX"; }
      $url = "http://ip-api.com/json/".urlencode($ip)."?fields=countryCode";
  
      if (LGSL::isEnabled("curl")) {
        $stream = new Stream(PROTOCOL::HTTP);
        $stream->open();
        $stream->write($url);
        $answer = $stream->readJson();
        $location_temp = $answer["countryCode"] ?? "XX";
        $stream->close();
      } 
	  
    if ($location_temp == "XX") {
        $country_url = "https://api.country.is/" . urlencode($ip) . "/";
        if ( function_exists("curl_init") && function_exists("curl_setopt") && function_exists("curl_exec") ) {
            $lgsl_curl = curl_init();
            curl_setopt($lgsl_curl, CURLOPT_HEADER, 0);
            curl_setopt($lgsl_curl, CURLOPT_TIMEOUT, 2);
            curl_setopt($lgsl_curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($lgsl_curl, CURLOPT_CONNECTTIMEOUT, 2);
            curl_setopt($lgsl_curl, CURLOPT_URL, $country_url);
            $answer = curl_exec($lgsl_curl);
            $answer = json_decode($answer, true);
            $location_temp = isset($answer["country"]) ? $answer["country"] : "XX";
            if (curl_error($lgsl_curl)) { $location_temp = "XX"; }
            curl_close($lgsl_curl);
        } 
	}
  
      if (strlen($location_temp) != 2) { $location_temp = "XX"; }

    if ($location_temp == "XX") {
        $loc_link = "https://ipinfo.io/" . $ip . "/country/";
        @$location_temp = (file_get_contents($loc_link)) ? file_get_contents($loc_link) : "XX";
    }

    $location = mb_convert_encoding($location_temp, 'UTF-8');

      return $location;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants