diff --git a/library/mysql.php b/library/mysql.php index 643499a..98d1db5 100644 --- a/library/mysql.php +++ b/library/mysql.php @@ -84,29 +84,45 @@ class MySQL { return $query->fetchAll(); } - public function getTopHosts() { - - $query = $this->_db->query("SELECT `hostPage`.`hostPageId`, - `hostPage`.`uri`, - `host`.`hostId`, - `host`.`scheme`, - `host`.`name`, - `host`.`port`, - (SELECT COUNT(*) FROM `hostPageToHostPage` - WHERE `hostPageToHostPage`.`hostPageIdTarget` = `hostPage`.`hostPageId` - AND (SELECT `hostPageSource`.`hostId` FROM `hostPage` AS `hostPageSource` - WHERE `hostPageSource`.`hostPageId` = `hostPageToHostPage`.`hostPageIdSource`) <> `hostPage`.`hostId`) AS `rank` - - FROM `hostPage` - JOIN `host` ON (`host`.`hostId` = `hostPage`.`hostId`) - - WHERE `host`.`status` = '1' - AND `hostPage`.`uri` = '/' - AND `hostPage`.`httpCode` = 200 - AND `hostPage`.`timeBanned` IS NULL - AND `hostPage`.`mime` IS NOT NULL - - ORDER BY `rank` DESC"); + public function getTopHostPages() { + + $query = $this->_db->query(" SELECT + + `hostPageTarget`.`hostId`, + `hostPageTarget`.`hostPageId`, + `hostPageTarget`.`uri`, + + `hostTarget`.`scheme`, + `hostTarget`.`name`, + `hostTarget`.`port`, + + ( + + SELECT COUNT(*) + + FROM `hostPageToHostPage` + JOIN `hostPage` AS `hostPageSource` ON (`hostPageSource`.`hostPageId` = `hostPageToHostPage`.`hostPageIdSource`) + + WHERE `hostPageToHostPage`.`hostPageIdTarget` = `hostPageTarget`.`hostPageId` + AND `hostPageSource`.`hostId` <> `hostPageTarget`.`hostId` + + ) AS `rank` + + FROM `hostPage` AS `hostPageTarget` + JOIN `host` AS `hostTarget` ON (`hostTarget`.`hostId` = `hostPageTarget`.`hostId`) + + WHERE `hostTarget`.`status` = '1' + AND `hostPageTarget`.`httpCode` = 200 + AND `hostPageTarget`.`timeBanned` IS NULL + AND `hostPageTarget`.`mime` IS NOT NULL + + GROUP BY `hostPageTarget`.`hostPageId` + + HAVING `rank` > 0 + + ORDER BY `rank` DESC + + "); return $query->fetchAll(); } diff --git a/public/top.php b/public/top.php index 8d6b073..b171037 100644 --- a/public/top.php +++ b/public/top.php @@ -229,20 +229,20 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the
- getTopHosts()) { ?> + getTopHostPages()) { ?> - + - $result) { ?> + $topHostPage) { ?> - +
- getLastPageDescription($result->hostPageId)) { ?> + getLastPageDescription($topHostPage->hostPageId)) { ?> title)) { ?> title) ?> description)) { ?> @@ -253,18 +253,18 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the - - identicon - scheme . '://' . $result->name . ($result->port ? ':' . $result->port : false))) ?> + + identicon + scheme . '://' . $topHostPage->name . ($topHostPage->port ? ':' . $topHostPage->port : false))) ?> - getTotalHostPages($result->hostId) ?> + getTotalHostPages($topHostPage->hostId) ?> = CRAWL_HOST_DEFAULT_PAGES_LIMIT ? '+' : false) ?> rank ?>rank ?> - +