| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/mahyarcake/www/wp-content/plugins/wp-statistics/includes/ |
Upload File : |
<?php
namespace WP_STATISTICS;
class Country
{
/**
* Default Unknown flag
*
* @var string
*/
public static $unknown_location = '000';
/**
* Get country codes
*
* @return array|bool|string
*/
public static function getList()
{
# Load From file
include WP_STATISTICS_DIR . "includes/defines/country-codes.php";
if (isset($ISOCountryCode)) {
return $ISOCountryCode;
}
return array();
}
/**
* Get Country flag
*
* @param $location
* @return string
*/
public static function flag($location)
{
$list_country = self::getList();
if (!array_key_exists($location, $list_country)) {
$location = self::$unknown_location;
}
return WP_STATISTICS_URL . 'assets/images/flags/' . strtolower($location) . '.svg';
}
/**
* Get Country name by Code
*
* @param $code
* @return mixed
*/
public static function getName($code)
{
$list_country = self::getList();
if (array_key_exists($code, $list_country)) {
return $list_country[$code];
}
return $list_country[self::$unknown_location];
}
/**
* get Top Country List
*
* @param array $args
* @return array
*/
public static function getTop($args = array())
{
global $wpdb;
// Load List Country Code
$ISOCountryCode = Country::getList();
// Get List From DB
$list = array();
// Check Default
if (empty($args['from']) and empty($args['to'])) {
if (array_key_exists($args['ago'], TimeZone::getDateFilters())) {
$dateFilter = TimeZone::calculateDateFilter($args['ago']);
$args['from'] = $dateFilter['from'];
$args['to'] = $dateFilter['to'];
}
}
// Check Custom Date
if (!empty($args['from']) and !empty($args['to'])) {
$count_day = TimeZone::getNumberDayBetween($args['from'], $args['to']);
} else {
if (is_numeric($args['ago']) and $args['ago'] > 0) {
$count_day = $args['ago'];
} else {
$first_day = Helper::get_date_install_plugin();
$count_day = TimeZone::getNumberDayBetween($first_day);
}
}
// Get time ago Days Or Between Two Days
if (!empty($args['from']) and !empty($args['to'])) {
$days_list = TimeZone::getListDays(array('from' => $args['from'], 'to' => $args['to']));
} else {
if (is_numeric($args['ago']) and $args['ago'] > 0) {
$days_list = TimeZone::getListDays(array('from' => TimeZone::getTimeAgo($args['ago'])));
} else {
$days_list = TimeZone::getListDays(array('from' => TimeZone::getTimeAgo($count_day)));
}
}
$days_time_list = array_keys($days_list);
// Get Result
$limitQuery = (isset($args['limit']) and $args['limit'] > 0) ? $wpdb->prepare("LIMIT %d", $args['limit']) : '';
$sqlQuery = $wpdb->prepare("SELECT `location`, COUNT(`location`) AS `count` FROM `" . DB::table('visitor') . "` WHERE `last_counter` BETWEEN %s AND %s GROUP BY location ORDER BY `count` DESC", reset($days_time_list), end($days_time_list));
$result = $wpdb->get_results($sqlQuery . " " . $limitQuery); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
foreach ($result as $item) {
$item->location = strtoupper($item->location);
$list[] = array(
'location' => $item->location,
'name' => $ISOCountryCode[$item->location],
'flag' => self::flag($item->location),
'link' => Menus::admin_url('visitors', array('location' => $item->location)),
'number' => $item->count
);
}
return $list;
}
}