From 407e0d7f185a534887b53b10dfdcb3235019eaa1 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 26 Jul 2023 12:51:00 +0300 Subject: [PATCH] implement top page --- library/mysql.php | 27 +++++ public/top.php | 284 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 311 insertions(+) create mode 100644 public/top.php diff --git a/library/mysql.php b/library/mysql.php index e5f3910..61e287e 100644 --- a/library/mysql.php +++ b/library/mysql.php @@ -84,6 +84,33 @@ 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"); + + return $query->fetchAll(); + } + public function getHosts() { $query = $this->_db->query('SELECT * FROM `host`'); diff --git a/public/top.php b/public/top.php new file mode 100644 index 0000000..8d6b073 --- /dev/null +++ b/public/top.php @@ -0,0 +1,284 @@ +getHostPagesTotal(); + +$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the new one...'), $totalPages), + sprintf(_('Over %s pages or enter the new one...'), $totalPages), + sprintf(_('Over %s pages or enter the new one...'), $totalPages), + ]); + + + +?> + + + + + <?php echo _('Top - YGGo!') ?> + + + + + + +
+
+

+ + +
+
+
+ getTopHosts()) { ?> + + + + + + + + + $result) { ?> + + + + + + + + +
+ getLastPageDescription($result->hostPageId)) { ?> + title)) { ?> + title) ?> + description)) { ?> + description) ?> + keywords)) { ?> + keywords) ?> + + + + + + identicon + scheme . '://' . $result->name . ($result->port ? ':' . $result->port : false))) ?> + + + getTotalHostPages($result->hostId) ?> + = CRAWL_HOST_DEFAULT_PAGES_LIMIT ? '+' : false) ?> + rank ?> + + + +
+ +
+ + getHostPageCrawlQueueTotal(time() - CRAWL_PAGE_SECONDS_OFFSET, time() - CRAWL_PAGE_HOME_SECONDS_OFFSET)) { ?> + + +
+ +
+ + \ No newline at end of file