Browse Source

add media referrers info

main
ghost 2 years ago
parent
commit
371670fadf
  1. 1
      README.md
  2. 20
      library/mysql.php
  3. 30
      public/search.php

1
README.md

@ -26,6 +26,7 @@ php-dom @@ -26,6 +26,7 @@ php-dom
php-pdo
php-curl
php-gd
php-mbstring
php-mysql
sphinxsearch
```

20
library/mysql.php

@ -323,7 +323,7 @@ class MySQL { @@ -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 { @@ -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) {

30
public/search.php

@ -292,6 +292,11 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) { @@ -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;
}
</style>
@ -317,7 +322,6 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) { @@ -317,7 +322,6 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
</div>
<?php foreach ($results as $result) { ?>
<?php if ($hostPage = $db->getFoundHostPage($result->id)) { ?>
<?php $hostPageURL = $hostPage->scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false) . $hostPage->uri ?>
<div>
<?php if ($hostPageDescription = $db->getLastPageDescription($result->id)) { ?>
<?php if (!empty($hostPageDescription->title)) { ?>
@ -330,10 +334,30 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) { @@ -330,10 +334,30 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
<span><?php echo $hostPageDescription->keywords ?></span>
<?php } ?>
<?php } ?>
<a href="<?php echo $hostPageURL ?>">
<a href="<?php echo $hostPage->scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false) . $hostPage->uri ?>">
<img src="<?php echo WEBSITE_DOMAIN; ?>/image.php?q=<?php echo urlencode($hostPage->name) ?>" alt="favicon" width="16" height="16" class="icon" />
<?php echo htmlentities(urldecode($hostPageURL)) ?>
<?php echo htmlentities(urldecode($hostPage->scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false)) . (mb_strlen(urldecode($hostPage->uri)) > 48 ? '...' . mb_substr(urldecode($hostPage->uri), -48) : urldecode($hostPage->uri))) ?>
</a>
<?php if ($result->mime != 'text' && $totalHostPageIdSources = $db->getTotalHostPageIdSourcesByHostPageIdTarget($result->id)) { ?>
<p><?php echo Filter::plural($totalHostPageIdSources, [sprintf(_('%s referrer'), $totalHostPageIdSources),
sprintf(_('%s referrers'), $totalHostPageIdSources),
sprintf(_('%s referrers'), $totalHostPageIdSources),
]) ?></p>
<?php foreach ($db->getHostPageIdSourcesByHostPageIdTarget($result->id) as $hostPageIdSource) { ?>
<?php if ($hostPage = $db->getFoundHostPage($hostPageIdSource->hostPageIdSource)) { ?>
<p>
<?php echo Filter::plural($hostPageIdSource->quantity, [sprintf(_('%s ref'), $hostPageIdSource->quantity),
sprintf(_('%s refs'), $hostPageIdSource->quantity),
sprintf(_('%s refs'), $hostPageIdSource->quantity),
]) ?>
<a href="<?php echo $hostPage->scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false) . $hostPage->uri ?>">
<img src="<?php echo WEBSITE_DOMAIN; ?>/image.php?q=<?php echo urlencode($hostPage->name) ?>" alt="favicon" width="16" height="16" class="icon" />
<?php echo htmlentities(urldecode($hostPage->scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false)) . (mb_strlen(urldecode($hostPage->uri)) > 48 ? '...' . mb_substr(urldecode($hostPage->uri), -48) : urldecode($hostPage->uri))) ?>
</a>
</p>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php } ?>

Loading…
Cancel
Save