use WP_STATISTICS\Country;
use WP_STATISTICS\IP;
use WP_STATISTICS\Pages;
use WP_Statistics\Service\Analytics\DeviceDetection\DeviceHelper;
use WP_Statistics\Service\Analytics\DeviceDetection\UserAgent;
use WP_Statistics\Service\Geolocation\GeolocationFactory;
use WP_Statistics\Service\Admin\PrivacyAudit\Faqs\RequireConsent;
use WP_STATISTICS\TimeZone;
use WP_STATISTICS\User;
/**
* Get Current User IP
*/
function wp_statistics_get_user_ip()
{
return IP::getIP();
}
/**
* Get Current User Data
*
* @throws Exception
*/
function wp_statistics_get_current_user_data()
{
// Get Current User country and City
$data = wp_statistics_get_user_location();
// Get Current User IP
$data['ip'] = wp_statistics_get_user_ip();
// Get User Agent contain Browser and Platform
$data['agent'] = UserAgent::getUserAgent();
// Get User info if Registered in WordPress
if (User::is_login()) {
$data['user'] = User::get();
}
// Return
return $data;
}
/**
* Get User Statistics Data By IP
*
* @param bool $ip
* @return array
* @throws Exception
*/
function wp_statistics_get_user_location($ip = false)
{
$ip = ($ip === false ? wp_statistics_get_user_ip() : $ip);
$data = array(
'country' => '',
'city' => '',
);
// Get the location
$location = GeolocationFactory::getLocation($ip);
$country = $location['country'];
$data['country'] = array(
'code' => $location,
'name' => Country::getName($country),
'flag' => Country::flag($country)
);
// Get User City
$data['city'] = $location['city'];
return $data;
}
/**
* Get Current Users online
*
* @param array $options
* @return mixed
*/
function wp_statistics_useronline($options = array())
{
global $wpdb;
//Check Parameter
$defaults = array(
/**
* Type Of Page in WordPress
* @See Frontend\get_page_type
*
* -- Acceptable values --
*
* post -> WordPress Post single page From All of public post Type
* page -> WordPress page single page
* product -> WooCommerce product single page
* home -> Home Page website
* category -> WordPress Category Page
* post_tag -> WordPress Post Tags Page
* tax -> WordPress Term Page for all Taxonomies
* author -> WordPress Users page
* 404 -> 404 Not Found Page
* archive -> WordPress Archive Page
* all -> All Site Page
*
*/
'type' => 'all',
/**
* WordPress Query object ID
* @example array('type' => 'product', 'ID' => 5)
*/
'ID' => 0,
/**
* Get number of logged users or all users
*
* -- Acceptable values --
* false -> Get Number of all users
* true -> Get Number of all logged users in wordpress
*/
'logged_users' => false,
/**
* Get number User From Custom Country
*
* -- Acceptable values --
* ISO Country Code -> For Get List @See \wp-statistics\includes\functions\country-code.php
*
*/
'location' => 'all',
/**
* Search Filter by User agent name
* e.g : Firefox , Chrome , Safari , Unknown ..
* @see wp_statistics_get_browser_list()
*
*/
'agent' => 'all',
/**
* Search filter by User Operating System name
* e.g : Windows, iPad, Macintosh, Unknown, ..
*
*/
'platform' => 'all',
/**
* Return Of Data
*
* -- Acceptable values --
* count -> Get number of user online
* all -> Get List of User Online data
*/
'return' => 'count'
);
// Parse incoming $args into an array and merge it with $defaults
$arg = wp_parse_args($options, $defaults);
//Basic SQL
$type_request = ($arg['return'] == "all" ? '*' : 'COUNT(*)');
$sql = "SELECT {$type_request} FROM " . WP_STATISTICS\DB::table('useronline') . " as useronline JOIN " . WP_STATISTICS\DB::table('visitor') . " as visitor ON useronline.visitor_id = visitor.ID";
//Check Where Condition
$where = [];
//Check Type of Page
if ($arg['type'] != "all") {
$where[] = "`visitor`.`last_page` = " . $arg['ID'];
}
//Check Custom user
if ($arg['logged_users'] === true) {
$where[] = "`user_id` > 0";
}
//Check Location
if ($arg['location'] != "all") {
$ISOCountryCode = Country::getList();
if (array_key_exists($arg['location'], $ISOCountryCode)) {
$where[] = "`location` = '" . $arg['location'] . "'";
}
}
//Check User Agent
if ($arg['agent'] != "all") {
$where[] = "`agent` = '" . $arg['agent'] . "'";
}
//Check User Platform
if ($arg['platform'] != "all") {
$where[] = "`platform` = '" . $arg['platform'] . "'";
}
//Push Conditions to SQL
if (!empty($where)) {
$sql .= ' WHERE ' . implode(' AND ', $where);
}
//Return Number od user Online
return ($arg['return'] == "count" ? $wpdb->get_var($sql) : $wpdb->get_results($sql)); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
/**
* This function get the visit statistics for a given time frame
*
* @param $time
* @param null $daily
* @return int
*/
function wp_statistics_visit($time, $daily = null)
{
global $wpdb;
//Date Column Name in visits table
$table_name = WP_STATISTICS\DB::table('visit');
$date_column = 'last_counter';
//Prepare Selector Sql
$selector = 'SUM(visit)';
if ($daily == true) {
$selector = '*';
}
//Generate Base Sql
$sql = "SELECT " . $selector . " FROM `" . $table_name . "` ";
//Create Sum Views variable
$sum = 0;
//Check if daily Report
if ($daily === true) {
// Check Sanitize Datetime
if (TimeZone::isValidDate($time)) {
$d = $time;
} else {
$d = TimeZone::getCurrentDate('Y-m-d', $time);
}
$result = $wpdb->get_row($sql . " WHERE `$date_column` = '" . $d . "'"); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
if (null !== $result) {
$sum = $result->visit;
}
} else {
//Generate MySql Time Conditions
if (is_array($time) && array_key_exists('start', $time) && array_key_exists('end', $time)) {
$mysql_time_sql = WP_STATISTICS\Helper::mysql_time_conditions($date_column, '', $time);
if (!empty($mysql_time_sql)) {
$sql = $sql . ' WHERE ' . $mysql_time_sql;
}
} else {
$mysql_time_sql = WP_STATISTICS\Helper::mysql_time_conditions($date_column, $time);
if (!empty($mysql_time_sql)) {
$sql = $sql . ' WHERE ' . $mysql_time_sql;
}
}
//Request To database
$result = $wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
//Custom Action
if ($time == "total") {
$result += WP_STATISTICS\Historical::get('visits');
}
$sum = $result;
}
return !is_numeric($sum) ? 0 : $sum;
}
/**
* This function gets the visitor statistics for a given time frame.
*
* @param $time
* @param null $daily
* @param bool $count_only
* @param array $options
* @return int|null|string
*/
function wp_statistics_visitor($time, $daily = null, $count_only = false, $options = array())
{
global $wpdb;
//Check Parameter
$defaults = array(
/**
* Type Of Page in WordPress
* @See Frontend\get_page_type
*
* -- Acceptable values --
*
* post -> WordPress Post single page From All of public post Type
* page -> WordPress page single page
* product -> WooCommerce product single page
* home -> Home Page website
* category -> WordPress Category Page
* post_tag -> WordPress Post Tags Page
* tax -> WordPress Term Page for all Taxonomies
* author -> WordPress Users page
* 404 -> 404 Not Found Page
* archive -> WordPress Archive Page
* all -> All Site Page
*
*/
'type' => 'all',
/**
* WordPress Query object ID
* @example array('type' => 'product', 'ID' => 5)
*/
'ID' => 0,
/**
* Get number User From Custom Country
*
* -- Acceptable values --
* ISO Country Code -> For Get List @See \wp-statistics\includes\functions\country-code.php
*
*/
'location' => 'all',
/**
* Search Filter by User agent name
* e.g : Firefox , Chrome , Safari , Unknown ..
* @see wp_statistics_get_browser_list()
*
*/
'agent' => 'all',
/**
* Search filter by User Operating System name
* e.g : Windows, iPad, Macintosh, Unknown, ..
*
*/
'platform' => 'all'
);
// Parse incoming $args into an array and merge it with $defaults
$arg = wp_parse_args($options, $defaults);
//Create History Visitors variable
$history = 0;
//Prepare Selector Sql
$date_column = 'last_counter';
$selector = '*';
if ($count_only == true) {
$selector = 'count(last_counter)';
}
//Generate Base Sql
if ($arg['type'] != "all" and WP_STATISTICS\Option::get('visitors_log') == true) {
$sql = "SELECT {$selector} FROM `" . WP_STATISTICS\DB::table('visitor') . "` INNER JOIN `" . WP_STATISTICS\DB::table("visitor_relationships") . "` ON `" . WP_STATISTICS\DB::table("visitor_relationships") . "`.`visitor_id` = `" . WP_STATISTICS\DB::table('visitor') . "`.`ID` INNER JOIN `" . WP_STATISTICS\DB::table('pages') . "` ON `" . WP_STATISTICS\DB::table('pages') . "`.`page_id` = `" . WP_STATISTICS\DB::table("visitor_relationships") . "` . `page_id`";
} else {
$sql = "SELECT {$selector} FROM `" . WP_STATISTICS\DB::table('visitor') . "`";
}
//Check Where Condition
$where = [];
//Check Type of Page
if ($arg['type'] != "all" and WP_STATISTICS\Option::get('visitors_log') == true) {
$where[] = "`" . WP_STATISTICS\DB::table('pages') . "`.`type`='" . $arg['type'] . "' AND `" . WP_STATISTICS\DB::table('pages') . "`.`page_id` = " . $arg['ID'];
}
//Check Location
if ($arg['location'] != "all") {
$ISOCountryCode = Country::getList();
if (array_key_exists($arg['location'], $ISOCountryCode)) {
$where[] = "`" . WP_STATISTICS\DB::table('visitor') . "`.`location` = '" . $arg['location'] . "'";
}
}
//Check User Agent
if ($arg['agent'] != "all") {
$where[] = "`" . WP_STATISTICS\DB::table('visitor') . "`.`agent` = '" . $arg['agent'] . "'";
}
//Check User Platform
if ($arg['platform'] != "all") {
$where[] = "`" . WP_STATISTICS\DB::table('visitor') . "`.`platform` = '" . $arg['platform'] . "'";
}
//Check Date Time report
if ($daily == true) {
// Check Sanitize Datetime
if (TimeZone::isValidDate($time)) {
$d = $time;
} else {
$d = TimeZone::getCurrentDate('Y-m-d', $time);
}
//Get Only Current Day Visitors
$where[] = "`" . WP_STATISTICS\DB::table('visitor') . "`.`last_counter` = '" . $d . "'";
} else {
//Generate MySql Time Conditions
if (is_array($time) && array_key_exists('start', $time) && array_key_exists('end', $time)) {
$mysql_time_sql = WP_STATISTICS\Helper::mysql_time_conditions($date_column, '', $time);
if (!empty($mysql_time_sql)) {
$sql = $sql . ' WHERE ' . $mysql_time_sql;
}
} else {
$mysql_time_sql = WP_STATISTICS\Helper::mysql_time_conditions($date_column, $time);
if (!empty($mysql_time_sql)) {
$where[] = $mysql_time_sql;
}
}
}
//Push Conditions to SQL
if (!empty($where)) {
$sql .= ' WHERE ' . implode(' AND ', $where);
}
//Custom Action
if ($time == "total" and $arg['type'] == "all") {
$history = WP_STATISTICS\Historical::get('visitors');
}
// Execute the SQL call, if we're only counting we can use get_var(), otherwise we use query().
if ($count_only == true) {
$sum = $wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$sum += $history;
} else {
$sum = $wpdb->query($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
return $sum;
}
/**
* This function returns the statistics for a given page.
*
* @param $time
* @param string $page_uri
* @param int $id
* @param null $rangestartdate
* @param null $rangeenddate
* @param bool $type
* @return int|null|string
*
* @todo Replace all instances of this function with `ViewsModel->countViews()`.
*/
function wp_statistics_pages($time, $page_uri = '', $id = -1, $rangestartdate = null, $rangeenddate = null, $type = false)
{
global $wpdb;
//Date Column Name in visits table
$table_name = WP_STATISTICS\DB::table('pages');
$date_column = 'date';
// History Vars
$history = 0;
$history_key = null;
$history_id = null;
//Check Where Condition
$where = [];
//Check Query By Page ID or Page Url
if ($type) {
$query = $wpdb->prepare("`type` = %s", $type);
if ($id != -1) {
$query .= $wpdb->prepare(" AND `id` = %d", $id);
$history_key = 'page';
$history_id = absint($id);
}
if ($page_uri != '') {
$page_uri_sql = esc_sql($page_uri);
$query .= $wpdb->prepare(" AND `URI` = %s", $page_uri_sql);
$history_key = 'uri';
$history_id = $page_uri;
}
$where[] = apply_filters('wp_statistics_pages_where_type_query', $query, $id, $type);
} else {
// If no page URI has been passed in, get the current page URI.
if ($page_uri == '') {
$page_uri = Pages::get_page_uri();
}
$page_uri_sql = esc_sql($page_uri);
// If a page/post ID has been passed, use it to select the rows, otherwise use the URI.
if ($id != -1) {
$where[] = "`id`= " . absint($id);
$history_key = 'page';
$history_id = absint($id);
} else {
$where[] = "`URI` = '{$page_uri_sql}'";
$history_key = 'uri';
$history_id = $page_uri;
}
}
//Custom Action
if ($time == "total") {
if ($history_key && $history_id) {
$history = WP_STATISTICS\Historical::get($history_key, $history_id);
}
}
//Prepare Time
$time_array = array();
if (is_numeric($time) || TimeZone::isValidDate($time)) {
$time_array['is_day'] = true;
}
if (!is_null($rangestartdate) and !is_null($rangeenddate)) {
$time_array = array('start' => $rangestartdate, 'end' => $rangeenddate);
}
//Check MySql Time Conditions
$mysql_time_sql = WP_STATISTICS\Helper::mysql_time_conditions($date_column, $time, $time_array);
if (!empty($mysql_time_sql)) {
$where[] = $mysql_time_sql;
}
//Generate Base Sql
$sql = "SELECT SUM(count) FROM {$table_name}";
//Push Conditions to SQL
if (!empty($where)) {
$sql .= ' WHERE ' . implode(' AND ', $where);
}
//Request Get data
$sum = $wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$sum += $history;
//Return Number Statistic
return ($sum == '' ? 0 : $sum);
}
/**
* Get top Pages between Time
*
* @param null $rangestartdate
* @param null $rangeenddate
* @param null $limit
* @param null $post_type
* @return array
*/
function wp_statistics_get_top_pages($rangestartdate = null, $rangeenddate = null, $limit = null, $post_type = null)
{
global $wpdb;
$spliceLimit = ($limit != null ? $limit : 5);
$limit = null;
// Get every unique URI from the pages database.
if ($rangestartdate != null && $rangeenddate != null) {
$whereType = ($post_type != null ? $wpdb->prepare(" AND `type`=%s", $post_type) : '');
$result = $wpdb->get_results(
$wpdb->prepare("SELECT `uri`,`id`,`type` FROM " . \WP_STATISTICS\DB::table('pages') . " WHERE `date` BETWEEN %s AND %s {$whereType} GROUP BY `id`" . ($limit != null ? ' LIMIT ' . $limit : ''), $rangestartdate, $rangeenddate), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
ARRAY_N);
} else {
$limitQuery = '';
if ($limit) {
$limitQuery = $wpdb->prepare(" LIMIT %d", $limit);
}
$whereType = ($post_type != null ? $wpdb->prepare(" WHERE `type`=%s", $post_type) : '');
$result = $wpdb->get_results("SELECT `uri`, `id`, `type` FROM " . \WP_STATISTICS\DB::table('pages') . " {$whereType} GROUP BY `id` {$limitQuery}", ARRAY_N); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
$total = 0;
$uris = array();
// Now get the total page visit count for each unique URI.
foreach ($result as $out) {
//Prepare item
list($url, $page_id, $page_type) = $out;
// Check if item is of specific post type (string or part of an array) or if post type is set to null
if (is_null($post_type) || $page_type == $post_type || (is_array($post_type) && in_array($page_type, $post_type))) {
// Increment the total number of results.
$total++;
//Get Page Title
$page_info = Pages::get_page_info($page_id, $page_type);
$title = mb_substr($page_info['title'], 0, 200, "utf-8");
$page_url = $page_info['link'];
// Check age Title if page id or type not exist
if ($page_info['link'] == "") {
$page_url = path_join(get_site_url(), $url);
$id = WP_STATISTICS\Pages::uri_to_id($out[0]);
$post = get_post($id);
if (is_object($post)) {
$title = esc_html($post->post_title);
} else {
if ($out[0] == '/') {
$title = get_bloginfo();
} else {
$title = '';
}
}
}
//Check Title is empty
if (empty($title)) {
$title = '-';
}
// Add the current post to the array.
if ($rangestartdate != null && $rangeenddate != null) {
$uris[] = array(
urldecode_deep($out[0]),
wp_statistics_pages('range', $out[0], -1, $rangestartdate, $rangeenddate, $post_type),
$page_id,
$title,
$page_url,
);
} else {
$uris[] = array(
urldecode_deep($out[0]),
wp_statistics_pages('total', $out[0], -1, $rangestartdate, $rangeenddate, $post_type),
$page_id,
$title,
$page_url
);
}
}
}
// If we have more than one result, let's sort them using usort.
if (count($uris) > 1) {
usort($uris, array('\WP_STATISTICS\Helper', 'compare_uri_hits_int'));
}
array_splice($uris, $spliceLimit);
return array($spliceLimit, $uris);
// return array($total, $uris);
}
/**
* Returns all unique user agents in the database.
*
* @param null $rangestartdate
* @param null $rangeenddate
* @return array
*/
function wp_statistics_ua_list($rangestartdate = null, $rangeenddate = null)
{
global $wpdb;
if ($rangestartdate != null && $rangeenddate != null) {
if ($rangeenddate == 'CURDATE()') {
$result = $wpdb->get_results(
$wpdb->prepare("SELECT DISTINCT agent FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `last_counter` BETWEEN %s AND CURDATE()", $rangestartdate),
ARRAY_N);
} else {
$result = $wpdb->get_results(
$wpdb->prepare("SELECT DISTINCT agent FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate),
ARRAY_N);
}
} else {
$result = $wpdb->get_results(
"SELECT DISTINCT agent FROM `" . \WP_STATISTICS\DB::table('visitor') . "` ",
ARRAY_N);
}
$Browsers = array();
$default_browser = DeviceHelper::getBrowserList();
foreach ($result as $out) {
//Check Browser is defined in wp-statistics
if (array_key_exists(strtolower($out[0]), $default_browser)) {
$Browsers[] = esc_html($out[0]);
}
}
return $Browsers;
}
/**
* Count User By User Agent
*
* @param $agent
* @param null $rangestartdate
* @param null $rangeenddate
* @return mixed
*/
function wp_statistics_useragent($agent, $rangestartdate = null, $rangeenddate = null)
{
global $wpdb;
if ($rangestartdate != null || $rangeenddate != null) {
if ($rangeenddate == null) {
$result = $wpdb->get_var(
$wpdb->prepare("SELECT COUNT(*) FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `agent` = %s AND `last_counter` = %s", $agent, $rangestartdate)
);
} else {
$result = $wpdb->get_var(
$wpdb->prepare("SELECT COUNT(*) FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `agent` = %s AND `last_counter` BETWEEN %s AND %s", $agent, $rangestartdate, $rangeenddate)
);
}
} else {
$result = $wpdb->get_var(
$wpdb->prepare("SELECT COUNT(*) FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `agent` = %s", $agent)
);
}
return $result;
}
/**
* Returns all unique platform types from the database.
*
* @param null $rangestartdate
* @param null $rangeenddate
* @return array
*/
function wp_statistics_platform_list($rangestartdate = null, $rangeenddate = null)
{
global $wpdb;
if ($rangestartdate != null && $rangeenddate != null) {
$result = $wpdb->get_results(
$wpdb->prepare("SELECT DISTINCT platform FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate),
ARRAY_N);
} else {
$result = $wpdb->get_results(
"SELECT DISTINCT platform FROM `" . \WP_STATISTICS\DB::table('visitor') . "` ",
ARRAY_N);
}
$Platforms = array();
foreach ($result as $out) {
$Platforms[] = esc_html($out[0]);
}
return $Platforms;
}
/**
* Returns the count of a given platform in the database.
*
* @param $platform
* @param null $rangestartdate
* @param null $rangeenddate
* @return mixed
*/
function wp_statistics_platform($platform, $rangestartdate = null, $rangeenddate = null)
{
global $wpdb;
if ($rangestartdate != null && $rangeenddate != null) {
$result = $wpdb->get_var(
$wpdb->prepare("SELECT COUNT(platform) FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `platform` = %s AND `last_counter` BETWEEN %s AND %s", $platform, $rangestartdate, $rangeenddate)
);
} else {
$result = $wpdb->get_var(
$wpdb->prepare("SELECT COUNT(platform) FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE `platform` = %s", $platform)
);
}
return $result;
}
/**
* Returns all unique versions for a given agent from the database.
*
* @param $agent
* @param null $rangestartdate
* @param null $rangeenddate
* @return array
*/
function wp_statistics_agent_version_list($agent, $rangestartdate = null, $rangeenddate = null)
{
global $wpdb;
if ($rangestartdate != null && $rangeenddate != null) {
$result = $wpdb->get_results(
$wpdb->prepare("SELECT DISTINCT `version` FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE agent = %s AND `last_counter` BETWEEN %s AND %s", $agent, $rangestartdate, $rangeenddate),
ARRAY_N);
} else {
$result = $wpdb->get_results(
$wpdb->prepare("SELECT DISTINCT `version` FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE agent = %s", $agent),
ARRAY_N);
}
$Versions = array();
foreach ($result as $out) {
$Versions[] = $out[0];
}
return $Versions;
}
/**
* Returns the statistics for a given agent/version pair from the database.
*
* @param $agent
* @param $version
* @param null $rangestartdate
* @param null $rangeenddate
* @return mixed
*/
function wp_statistics_agent_version($agent, $version, $rangestartdate = null, $rangeenddate = null)
{
global $wpdb;
if ($rangestartdate != null && $rangeenddate != null) {
$result = $wpdb->get_var(
$wpdb->prepare("SELECT COUNT(version) FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE agent = %s AND version = %s AND `last_counter` BETWEEN %s AND %s", $agent, $version, $rangestartdate, $rangeenddate)
);
} else {
$result = $wpdb->get_var(
$wpdb->prepare("SELECT COUNT(version) FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE agent = %s AND version = %s", $agent, $version)
);
}
return $result;
}
/**
* Return the SQL WHERE clause for getting the search engine.
*
* @param string $search_engine
* @return bool|string
*/
function wp_statistics_searchengine_query($search_engine = 'all')
{
global $wpdb;
$search_query = '';
// Are we getting results for all search engines or a specific one?
if (strtolower($search_engine) == 'all') {
$search_query .= "`source_channel` in ('search')";
} else {
// Are we getting results for all search engines or a specific one?
$search_query .= $wpdb->prepare("`source_name` = %s", $search_engine);
}
return $search_query;
}
/**
* Get Search engine Statistics
*
* @param string $search_engine
* @param string $time
* @param string $search_by [query / name]
* @param array $range
* @return mixed
*/
function wp_statistics_get_search_engine_query($search_engine = 'all', $time = 'total', $search_by = 'query', $range = [])
{
global $wpdb;
//Prepare Table Name
$table_name = \WP_STATISTICS\DB::table('visitor');
//Date Column table
$date_column = 'last_counter';
// Get a complete list of search engines
if ($search_by == "query") {
$search_query = wp_statistics_searchengine_query($search_engine);
}
//Generate Base Sql
$sql = "SELECT COUNT(ID) FROM {$table_name} WHERE ({$search_query})";
// Check Sanitize Datetime
if (TimeZone::isValidDate($time)) {
if (empty($range)) $range = ['is_day' => true];
} else {
if (empty($range)) $range = ['current_date' => true];
}
$mysql_time_sql = WP_STATISTICS\Helper::mysql_time_conditions($date_column, $time, $range);
//Generate MySql Time Conditions
if (!empty($mysql_time_sql)) {
$sql = $sql . ' AND (' . $mysql_time_sql . ')';
}
//Request Data
return $wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
/**
* This function will return the statistics for a given search engine.
*
* @param string $search_engine
* @param string $time
* @param array $range
* @return mixed
*/
function wp_statistics_searchengine($search_engine = 'all', $time = 'total', $range = [])
{
return wp_statistics_get_search_engine_query($search_engine, $time, $search_by = 'query', $range);
}
/**
* Return Refer List
*
* @param null $time
* @param array $range
* @return int
*/
function wp_statistics_referrer($time = null, $range = [])
{
global $wpdb;
$sql = "SELECT `referred` FROM `" . \WP_STATISTICS\DB::table('visitor') . "` WHERE referred <> ''";
// Check Sanitize Datetime
if (TimeZone::isValidDate($time)) {
if (empty($range)) $range = ['is_day' => true];
} else {
if (empty($range)) $range = ['current_date' => true];
}
$mysql_time_sql = WP_STATISTICS\Helper::mysql_time_conditions('last_counter', $time, $range);
//Generate MySql Time Conditions
if (!empty($mysql_time_sql)) {
$sql = $sql . ' AND (' . $mysql_time_sql . ')';
}
$result = $wpdb->get_results($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$urls = array();
foreach ($result as $item) {
$url = wp_parse_url($item->referred);
if (empty($url['host']) || stripos(get_bloginfo('url'), $url['host']) !== false) {
continue;
}
$urls[] = $url['scheme'] . '://' . $url['host'];
}
$get_urls = array_count_values($urls);
return count($get_urls);
}
/**
* Checks if consent is required for collecting user statistics.
*
* This function evaluates several conditions that determine whether consent
* is needed to collect and store user data for statistics purposes. If any
* of the conditions are not met, it indicates that consent is required.
*
* @return bool Returns true if consent is required, false otherwise.
* @since 14.10.1
*/
function wp_statistics_needs_consent()
{
// Get the current status of the consent requirement
$status = RequireConsent::getStatus();
// Check if consent is required
if ($status == 'warning') {
return true; // Consent is required
}
// Return false if consent is not required
return false;
}
安大略省汉密尔顿10个令人惊叹的历史建筑 ⋆ 晒鱼
Skip to content
凭借其工业和经济活动的骄人的历史和安大略湖的战略位置,汉密尔顿被称为”雄心勃勃的城市”也就不足为奇了。 而且,用这样一个名字,你会期望这个城市的一些最有钱的居民会有一些相当雄心勃勃的房子……。 你绝对是对的!
所以准备好一些优雅的汉密尔顿物业,其中一些价格可能会让你感到惊讶。 正如当地房地产经纪人科莱特·库珀(Colette Cooper)恰当地表示的那样,”这些高端物业的价值与多伦多相比是非常出色的,在多伦多市场,这个价格可能会翻倍至三倍。”
这是我特别喜欢的房屋清单。 有些仍然可以购买; 其他人已经被越来越多的热爱家庭的粉丝所吸引,他们对汉密尔顿丰富而历史悠久的氛围非常满意。 请享用!
所有照片由Tom Vogel提供
1.
26 Ravenscliffe Avenue, Hamilton, Ontario
当前叫价: $3,899,900加币
这是汉密尔顿建筑师詹姆斯·贝尔福特(James Balfour)1881年的杰作,
目前在市场上刚刚上市,价格为389万美元。令人难以置信的是,这比2014年3月上市时的159万美元的价格上涨了145%。这座面积达11000平方英尺的石头和砖头大厦最初坐落在占地9英亩的土地上,但是,第一次世界大战后,这座富丽堂皇的庄园地块逐渐被分割规划,并出售给其他人并建了漂亮的房子(全部仍然完好)。
长长的车道面对Ravenscliffe大街,当地房地产经纪人Colette Copper称这是那些欣赏汉密尔顿历史悠久的地区的人们”值得一看”的街道。
Twenty-six Ravenscliffe 已然成了一个字符符号,具有戏剧性的屋顶线,高大的窗户,多个塔楼,12’天花板,美丽的雕刻木制品,装饰,梁和复杂的石膏模型,10间卧室和五个半浴室,大门厅,两个楼梯,包括原来的楼梯,前管家的宿舍,在卧室广阔的着陆,再加上一个真正的城堡不断提供悬崖和城市风景如画的意见。相当令人垂涎,不是吗?当地房地产专业人士Doug Folsetter说:”Ravenscliffe的城堡很容易成为有史以来在这个城市出售的最大的单一家庭住宅之一。
2.
316 James Street South, Unit D, Hamilton, Ontario
2015 年已售出 . 当时叫价 : $329,900 加币
汉密尔顿高级文化规划师前市长尼娜·查普尔(Nina Chapple)说,”在现存的建筑中,巴利纳欣Ballinahinch是一座沿着悬崖低肩横贯而过的十八世纪五十年代石制建筑的最后一栋建筑。这是一个绝对令人惊叹的区域。”
第二次世界大战后,税收上涨,对一个家庭来说,房子变得太昂贵。所以它就被改成成了公寓式建筑。然后在1980年,由一个建筑公司购买,这些建筑师保留了房子的有趣特色,同时建造了几个公寓单位,其中包括去年在市场上一上市就被迅速抢占的D单元。
这间两卧室公寓设有12英尺高的天花板,硬木地板,大窗户,大理石地幔,一个令人惊叹的私人露台可通过像故事书中的的哥特式门廊进入,内设彩色玻璃嵌板。难怪它一上市就卖掉了!我很惊诧他们是否知道在二十世纪四十年代中期,著名的Evelyn Dick 伊夫林·迪克(The Torso Murderer)让3号公寓招待男性朋友。
3.
403 Queen Street South, Hamilton, Ontario
当前叫价 : $4,250,000 加币
这个有20间客房,9壁炉房子,足以满足您的所有渴望复古的个性。如果它能以425万美元的价格出售后,这将是汉密尔顿 – 伯灵顿房地产经纪人协会录制的最昂贵的房屋销售。
403 Queen St S 这个建筑 统领着皇后街山的东南端,接着从皇后南街到赫斯的整个街区。汉密尔顿的每个人都知道这个地址,并皆有一个拥有它的梦想。这个家一直是多部电影制作的场景,引人瞩目的观众与其周围壮观的铁艺围栏。
具有令人惊叹的特点,包括超过一英亩的公园般的花园与百年老树,大理石门厅和2层楼梯,日光浴与原始拱形铅玻璃窗户,原木橡木地板和2英尺高踢脚线,7间大卧室(每个卧室都享有自己的浴缸!),一个绿洲盐水游泳池,可供12个人用的喷水水疗中心,1200平方英尺铺设的庭院和2个室外房间,以及一个室外的石头壁炉。
4.
250 James Street South, Hamilton, Ontario
2014 年售出 . 当时叫价 : $725,000 加币
这座三层独立的维多利亚式房屋建于1880年,由当地建筑师James Balfour设计,被称为历史悠久的Balfour House。被指定为历史遗产,这个房子是汉密尔顿第二帝国建筑最好的例子之一。
250 James Street South的外部平面包括拱形窗户的对称式门面,一扇整齐的乔治四世(George IV)式门廊,一扇分体式的聚光灯,一个优雅的双层屋顶,一个完美的天窗,以及时代的装饰性对比砖。
5000平方英尺的房子拥有4个大理石壁炉,两个东方式的的按摩浴缸和1880年代稻穗地幔式镜子仍在原地保存完好! 其他值得夸耀的特色包括主楼11英尺高的天花板(二楼10英尺的天花板),天花是复杂的石膏装饰造型,落地式拱形窗户,拱形门廊,现代墙纸,原装在厨房里的服务呼唤铃和一个大的旋转楼梯。
5.
5 Ravenscliffe Avenue, Hamilton, Ontario
2014 年售出 . 当时叫价 : $1,299,000 加币
20世纪早期的复古,令人难以忘怀的爱奥尼亚式柱子,杰出的楼梯扶手,迷人的天花板,美丽的斜面玻璃,完美的大门和复杂的镶嵌地板 – 5 Ravenscliffe的上市是2014年夏季房地产界无可争议的一大盛事。 上市价格达到了129.9万元,凭借其无与伦比的建筑优势赢得了每一块钱,更不用说它在汉密尔顿最好的街道上的位置了。
其他亮点包括5间卧室+3.5个浴室,10’天花板,12″踢脚线,原来的含铅玻璃,宽敞的门厅,一个壮观的太阳房,以及一个巨大的100’×188’公园般的花园在城市正中心地段,以及原来的仆人从主楼到三楼的楼梯。
6.
70 Aberdeen Avenue, Hamilton, Ontario
2015 年售出 . 当时叫价 : $1,150,000 加币
“South of Aberdeen”已成为汉密尔顿房地产(Hamilton Real Estate)在位于这条历史悠久的绿树成荫的街道上的一个主要卖点,难怪成为这座城市最令人印象深刻的一些住宅。 被称为戈登之家的70 Aberdeen也不不会感到例外。
这个由Pigott建筑公司建造的1932年庄园是汉密尔顿地标的家庭建筑之一。 它坐落在一个华丽的68×263英尺公园般的地段,忽略了城市的观念。 其他新鲜的特色包括:一个26x 50英尺的地面游泳池,一个经典的中心大厅,充足的窗户与石制门楣,橡木硬木地板镶嵌,高高的天花板,2个壁炉与手工周边,8英寸踢脚板,石膏墙壁 和天花板造型和一个高度步行的社区。
7.
73 Aberdeen Avenue, Hamilton, Ontario
2014 年售出 . 当时叫价 : $1,299,000 加币
光临1925年的格鲁吉亚盛式建筑,你会因为它的雄伟壮观而屏住呼吸。 我们特别佩服前门两侧的外观和华丽的铁笼灯。 很明显,从来没有进入内部,走在前门的长长的小路你会表露出惊喜。
坐落在有着良好口碑的Durand社区,73 Aberdeen swooned的买家被送有原装的硬木地板带红木镶嵌,10英尺的天花板,石膏檐口,原装的天花造型,护墙板,多个壁炉,法式门,内置书柜,定制衣柜,7间卧室, 一个正式的独立餐厅,橱窗和橱柜以及一个全年开放的俯瞰着花园的阳光房。
8.
77 Claremont Drive, Hamilton, Ontario
2014 年售出 . 当时叫价 : $1,098,000
被称为”Chisolm Home”,这个1850年代坚固的石灰石庄园,在联邦成立以前就坐落在带有安大略湖景色和远眺多伦多景色的悬崖边了。
以前的屋主在怀特亨指导过修复过程,曾经把古董墙纸与原定制相匹配并重新制作。 可悲的是,它在最近上市时被去除了。 幸运的是,剩下的特点足以化解这场悲剧。
其特点包括在家庭室进口红木镶板,3个燃气壁炉,2个阳光房,4间卧室和4个浴室(2套房),全硬木铺设,厨师的美食厨房与花岗岩柜台,3个水槽和工作站和高端家电, 品酒室与法式门直出到令人惊叹的后院绿洲与花园小径,美丽的花园,和一个精致的跳板水池(加热,盐水和夜间照明)。
9.
13 Inglewood Drive, Hamilton, Ontario
2013 年售出 . 当时叫价 : $679,000 加币
摄影师汤姆·沃格尔(www.vogel-creative.com)与英格伍德有着十多年的恋情。从规格拍摄到众多的iSpace虚拟游览 – 他已经经历了几乎所有的一切,仍然无法获得足够的宏伟。高耸的彩色玻璃(20英尺),手雕栏杆,高高的天花板,私密花园 – 不胜枚举。用他的话来说,”就像在汉密尔顿的中心拍摄唐顿庄园”。
在13 Inglewood,国王乔治套房(主卧)是这个公寓在2层楼的阔绰的3250平方英尺的最大的单位。它夸张着自己的地址,并可以通过别墅原来的正门进入。
这座1850年的哥特式复兴公寓内部经过了彻底的翻新,并在上市时进行了精美的装修。其特点包括一个扇拱形天花板,宏伟的原木雕刻的橡木楼梯,石膏天花板,可与欧式相媲美,英式庄园式花园,原木百叶窗,21英寸踢脚板,黑色大理石燃木壁炉以及包括人字形在内的全新装修的厨房马赛克大理石地砖。
10.
6 Bulls Lane, Hamilton, Ontario
2013 年售出 . 当时叫价 : $1,550,000 加币
两年前这个产业在市场上出现时,许多人心跳不已。 这样的机会很少可用。 这个结实的格鲁吉亚的石头特色的家曾经被称为山眉上的”悬崖”。 在约翰街上方,”The Cliff”建于1879年,由布尔家族用当地石灰岩建造。 在1920年进行了加建,但幸好没有掩饰格鲁吉亚建筑的经典对称性。
除了拥有价值百万元的城市景观外,这个拥有7间卧室和4.5间浴室的梦幻庄园还设有3个壁炉(2个燃木),超大主卧,并可步出到游泳池和多个庭院露台,整个3层楼漂亮的原木地板 ,一个完成的阁楼,步入式衣柜,一个书房,家庭办公室,阅读室,2个楼梯,一个石头外装饰式车库,专业园景花园和一条私家小径。
文章导航