mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-12 07:48:34 +00:00
delete getFoundHostPage method, update API version
This commit is contained in:
parent
11e02da66d
commit
02612d098b
@ -396,7 +396,7 @@ define('CRAWL_MANIFEST', true);
|
||||
* Manifest API version compatibility
|
||||
*
|
||||
*/
|
||||
define('CRAWL_MANIFEST_API_VERSION', 0.10);
|
||||
define('CRAWL_MANIFEST_API_VERSION', 0.11);
|
||||
|
||||
/*
|
||||
* Set default auto-crawl status for new manifest added
|
||||
|
@ -295,41 +295,6 @@ class MySQL {
|
||||
return $query->fetch();
|
||||
}
|
||||
|
||||
public function getFoundHostPage(int $hostPageId) {
|
||||
|
||||
$query = $this->_db->prepare("SELECT `hostPage`.`hostPageId`,
|
||||
`hostPage`.`uri`,
|
||||
`hostPage`.`timeAdded`,
|
||||
`hostPage`.`timeUpdated`,
|
||||
`hostPage`.`mime`,
|
||||
`hostPage`.`size`,
|
||||
|
||||
`host`.`scheme`,
|
||||
`host`.`name`,
|
||||
`host`.`port`,
|
||||
|
||||
IF (`host`.`port` IS NOT NULL,
|
||||
CONCAT(`host`.`scheme`, '://', `host`.`name`, ':', `host`.`port`),
|
||||
CONCAT(`host`.`scheme`, '://', `host`.`name`)
|
||||
) AS `hostURL`,
|
||||
|
||||
IF (`host`.`port` IS NOT NULL,
|
||||
CONCAT(`host`.`scheme`, '://', `host`.`name`, ':', `host`.`port`, `hostPage`.`uri`),
|
||||
CONCAT(`host`.`scheme`, '://', `host`.`name`, `hostPage`.`uri`)
|
||||
) AS `hostPageURL`
|
||||
|
||||
FROM `hostPage`
|
||||
JOIN `host` ON (`host`.`hostId` = `hostPage`.`hostId`)
|
||||
|
||||
WHERE `hostPage`.`hostPageId` = ?
|
||||
|
||||
LIMIT 1");
|
||||
|
||||
$query->execute([$hostPageId]);
|
||||
|
||||
return $query->fetch();
|
||||
}
|
||||
|
||||
public function addHostPage(int $hostId,
|
||||
int $crc32uri,
|
||||
string $uri,
|
||||
|
@ -22,13 +22,13 @@ class SphinxQL {
|
||||
|
||||
public function searchHostPages(string $keyword, string $mime, int $start, int $limit, int $maxMatches) {
|
||||
|
||||
$query = $this->_sphinx->prepare("SELECT *, WEIGHT() + `rank` * IF (`rank` > 0, 1000, 1) AS `priority`
|
||||
$query = $this->_sphinx->prepare("SELECT *, WEIGHT() + `rank` * IF (`rank` > 0, 1000, 1) AS `weight`
|
||||
|
||||
FROM `hostPage`
|
||||
|
||||
WHERE MATCH(?) AND `mime` = ?
|
||||
|
||||
ORDER BY `priority` DESC, WEIGHT() DESC
|
||||
ORDER BY `weight` DESC, WEIGHT() DESC
|
||||
|
||||
LIMIT " . (int) ($start >= $maxMatches ? ($maxMatches > 0 ? $maxMatches - 1 : 0) : $start) . "," . (int) $limit . "
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// Current version
|
||||
define('API_VERSION', 0.10);
|
||||
define('API_VERSION', 0.11);
|
||||
|
||||
// Load system dependencies
|
||||
require_once(__DIR__ . '/../config/app.php');
|
||||
@ -44,13 +44,18 @@ if (API_ENABLED) {
|
||||
|
||||
foreach ($sphinxResults as $i => $sphinxResult) {
|
||||
|
||||
if ($hostPage = $db->getFoundHostPage($sphinxResult->id)) {
|
||||
if ($hostPage = $db->getHostPage($sphinxResult->id)) {
|
||||
|
||||
if ($host = $db->getHost($hostPage->hostId)) {
|
||||
|
||||
$dbResults[$i] = $hostPage;
|
||||
|
||||
$dbResults[$i]->url = $host->url . $hostPage->uri;
|
||||
|
||||
$dbResults[$i]->weight = $sphinxResult->weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make response
|
||||
$response = [
|
||||
|
@ -203,7 +203,8 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the
|
||||
</form>
|
||||
</header>
|
||||
<main>
|
||||
<?php if ($hostPage = $db->getFoundHostPage($hp)) { ?>
|
||||
<?php if ($hostPage = $db->getHostPage($hp)) { ?>
|
||||
<?php if ($host = $db->getHost($hostPage->hostId)) { ?>
|
||||
<div>
|
||||
<?php if ($hostPageDescription = $db->getLastPageDescription($hp)) { ?>
|
||||
<?php if (!empty($hostPageDescription->title)) { ?>
|
||||
@ -216,9 +217,9 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the
|
||||
<span><?php echo htmlentities($hostPageDescription->keywords) ?></span>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<a href="<?php echo $hostPage->hostPageURL ?>">
|
||||
<img src="<?php echo WEBSITE_DOMAIN; ?>/file.php?type=identicon&query=<?php echo urlencode($hostPage->name) ?>" alt="identicon" width="16" height="16" class="icon" />
|
||||
<?php echo htmlentities(urldecode($hostPage->hostURL) . urldecode($hostPage->uri)) ?>
|
||||
<a href="<?php echo urldecode($host->url . $hostPage->uri) ?>">
|
||||
<img src="<?php echo WEBSITE_DOMAIN; ?>/file.php?type=identicon&query=<?php echo urlencode($host->name) ?>" alt="identicon" width="16" height="16" class="icon" />
|
||||
<?php echo htmlentities(urldecode($host->url . $hostPage->uri)) ?>
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
@ -261,13 +262,12 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the
|
||||
</p>
|
||||
<?php if ($totalHostPageIdSources) { ?>
|
||||
<?php foreach ($db->getHostPagesToHostPageByHostPageIdTarget($hp) as $hostPageIdSource) { ?>
|
||||
<?php if ($hostPage = $db->getFoundHostPage($hostPageIdSource->hostPageIdSource)) { ?>
|
||||
<?php $hostPageDescription = $db->getLastPageDescription($hostPageIdSource->hostPageIdSource); ?>
|
||||
<?php if ($hostPage = $db->getHostPage($hostPageIdSource->hostPageIdSource)) { ?>
|
||||
<?php if ($host = $db->getHost($hostPage->hostId)) { ?>
|
||||
<p>
|
||||
<a href="<?php echo $hostPage->hostPageURL ?>"
|
||||
title="<?php echo (!empty($hostPageDescription->title) ? $hostPageDescription->title : (!empty($hostPageDescription->description) ? $hostPageDescription->description : false)) ?>">
|
||||
<img src="<?php echo WEBSITE_DOMAIN; ?>/file.php?type=identicon&query=<?php echo urlencode($hostPage->name) ?>" alt="identicon" width="16" height="16" class="icon" />
|
||||
<?php echo htmlentities(urldecode($hostPage->hostURL) . (mb_strlen(urldecode($hostPage->uri)) > 32 ? '...' . mb_substr(urldecode($hostPage->uri), -32) : urldecode($hostPage->uri))) ?>
|
||||
<a href="<?php echo urldecode($host->url . $hostPage->uri) ?>">
|
||||
<img src="<?php echo WEBSITE_DOMAIN; ?>/file.php?type=identicon&query=<?php echo urlencode($host->name) ?>" alt="identicon" width="16" height="16" class="icon" />
|
||||
<?php echo htmlentities(urldecode($host->url) . (mb_strlen(urldecode($hostPage->uri)) > 28 ? '...' . mb_substr(urldecode($hostPage->uri), -28) : urldecode($hostPage->uri))) ?>
|
||||
</a>
|
||||
|
|
||||
<a href="<?php echo WEBSITE_DOMAIN; ?>/explore.php?hp=<?php echo $hostPage->hostPageId ?>">
|
||||
@ -277,7 +277,9 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<div style="text-align:center">
|
||||
<span><?php echo _('Not found') ?></span>
|
||||
|
@ -318,7 +318,8 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php foreach ($results as $result) { ?>
|
||||
<?php if ($hostPage = $db->getFoundHostPage($result->id)) { ?>
|
||||
<?php if ($hostPage = $db->getHostPage($result->id)) { ?>
|
||||
<?php if ($host = $db->getHost($hostPage->hostId)) { ?>
|
||||
<div>
|
||||
<?php if ($hostPageDescription = $db->getLastPageDescription($result->id)) { ?>
|
||||
<?php if (!empty($hostPageDescription->title)) { ?>
|
||||
@ -331,9 +332,9 @@ 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 $hostPage->hostPageURL ?>">
|
||||
<img src="<?php echo WEBSITE_DOMAIN; ?>/file.php?type=identicon&query=<?php echo urlencode($hostPage->name) ?>" alt="identicon" width="16" height="16" class="icon" />
|
||||
<?php echo htmlentities(urldecode($hostPage->hostURL) . (mb_strlen(urldecode($hostPage->uri)) > 28 ? '...' . mb_substr(urldecode($hostPage->uri), -28) : urldecode($hostPage->uri))) ?>
|
||||
<a href="<?php echo urldecode($host->url . $hostPage->uri) ?>">
|
||||
<img src="<?php echo WEBSITE_DOMAIN; ?>/file.php?type=identicon&query=<?php echo urlencode($host->name) ?>" alt="identicon" width="16" height="16" class="icon" />
|
||||
<?php echo htmlentities(urldecode($host->url) . (mb_strlen(urldecode($hostPage->uri)) > 28 ? '...' . mb_substr(urldecode($hostPage->uri), -28) : urldecode($hostPage->uri))) ?>
|
||||
</a>
|
||||
|
|
||||
<a href="<?php echo WEBSITE_DOMAIN; ?>/explore.php?hp=<?php echo $result->id ?>">
|
||||
@ -342,6 +343,7 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ($p * WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT <= $resultsTotal) { ?>
|
||||
<div>
|
||||
<a href="<?php echo WEBSITE_DOMAIN; ?>/search.php?q=<?php echo urlencode(htmlentities($q)) ?>&t=<?php echo $t ?>&m=<?php echo $m ?>&p=<?php echo $p + 1 ?>"><?php echo _('Next page') ?></a>
|
||||
|
Loading…
Reference in New Issue
Block a user