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; }
function fs_echo_country_flag_url($country_code) { echo fs_get_country_flag_url($country_code); }
function fs_api_get_country_flag_image($ip_address) { require_once dirname(__FILE__) . '/ip2country.php'; $code = fs_ip2c($ip_address); if ($code != false) { return fs_get_country_flag_url($code); } else { return ''; } }
function fs_add_comment_flag($link) { $FS_PATH = fs_get_firestats_path(); if (!$FS_PATH) { return; } require_once $FS_PATH . '/php/ip2country.php'; $ip = get_comment_author_IP(); $code = fs_ip2c($ip); if (!$code) { return $link; } return $link . ' ' . fs_get_country_flag_url($code); }