Ejemplo n.º 1
0
function fs_get_country_flag_url($country_code, $is_int = false)
{
    if ($is_int && $country_code != NULL) {
        $c = chr($country_code >> 8 & 0xff) . chr($country_code & 0xff);
        $country_code = $c;
    }
    if (!$country_code) {
        return "";
    }
    $code = strtolower($country_code);
    $flag_url = fs_url("img/flags/{$code}.png");
    $name = fs_get_country_name($code);
    return fs_get_flag_img_tag($name, $flag_url);
}
Ejemplo n.º 2
0
function fs_get_country_codes_percentage($num_limit, $days_ago)
{
    require_once dirname(__FILE__) . '/ip2country.php';
    $codes = fs_get_country_codes($days_ago);
    if ($codes === false) {
        return false;
    }
    if (count($codes) == 0) {
        return array();
    }
    $total = 0;
    foreach ($codes as $code) {
        $total += $code->c;
    }
    $t = 0;
    $res = array();
    $tp = 0;
    foreach ($codes as $code) {
        if ($t == $num_limit) {
            break;
        }
        $t++;
        $percentage = $code->c / (double) $total * 100;
        $code->percentage = $percentage;
        $intcode = $code->country_code;
        $code->name = fs_get_country_name($intcode, true);
        $code->img = fs_get_country_flag_url($intcode, true);
        $res[] = $code;
        $tp += $percentage;
    }
    if ($tp < 100) {
        $last = new stdClass();
        $last->percentage = 100 - $tp;
        $last->name = fs_r('Others');
        $last->img = fs_get_flag_img_tag($last->name, fs_url("img/others.png"));
        $res[] = $last;
    }
    return $res;
}