diff --git a/README.md b/README.md index 056c74f..bf1ae50 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ php-dom php-pdo php-curl php-gd +php-mbstring php-mysql sphinxsearch ``` diff --git a/library/mysql.php b/library/mysql.php index f62780d..a5b3013 100644 --- a/library/mysql.php +++ b/library/mysql.php @@ -323,7 +323,7 @@ class MySQL { public function addHostPageToHostPage(int $hostPageIdSource, int $hostPageIdTarget) { - $query = $this->_db->prepare('INSERT INTO `hostPageToHostPage` (`hostPageIdSource`, `hostPageIdTarget`, `quantity`) VALUES (?, ?, 0) + $query = $this->_db->prepare('INSERT INTO `hostPageToHostPage` (`hostPageIdSource`, `hostPageIdTarget`, `quantity`) VALUES (?, ?, 1) ON DUPLICATE KEY UPDATE `quantity` = `quantity` + 1'); @@ -340,6 +340,24 @@ class MySQL { return $query->rowCount(); } + public function getTotalHostPageIdSourcesByHostPageIdTarget(int $hostPageIdTarget) { + + $query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostPageToHostPage` WHERE `hostPageIdTarget` = ?'); + + $query->execute([$hostPageIdTarget]); + + return $query->fetch()->total; + } + + public function getHostPageIdSourcesByHostPageIdTarget(int $hostPageIdTarget, int $limit = 5) { + + $query = $this->_db->prepare('SELECT * FROM `hostPageToHostPage` WHERE `hostPageIdTarget` = ? ORDER BY `quantity` DESC LIMIT ' . (int) $limit); + + $query->execute([$hostPageIdTarget]); + + return $query->fetchAll(); + } + // Cleaner tools public function getCleanerQueue(int $limit, int $timeFrom) { diff --git a/public/search.php b/public/search.php index ba80f97..9abdb9c 100644 --- a/public/search.php +++ b/public/search.php @@ -292,6 +292,11 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) { p { margin: 16px 0; text-align: right; + font-size: 11px; + } + + p > a { + font-size: 11px; } @@ -317,7 +322,6 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) { getFoundHostPage($result->id)) { ?> - scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false) . $hostPage->uri ?>
+ quantity, [sprintf(_('%s ref'), $hostPageIdSource->quantity), + sprintf(_('%s refs'), $hostPageIdSource->quantity), + sprintf(_('%s refs'), $hostPageIdSource->quantity), + ]) ?> + + + scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false)) . (mb_strlen(urldecode($hostPage->uri)) > 48 ? '...' . mb_substr(urldecode($hostPage->uri), -48) : urldecode($hostPage->uri))) ?> + +
+ + +