mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 14:23:57 -07:00
Merge a556a6146c
into f64c340563
This commit is contained in:
commit
ed07788c76
6 changed files with 49 additions and 0 deletions
|
@ -14,6 +14,7 @@ require __DIR__ . '/common.php';
|
|||
$page_cfg['load_tpl_vars'] = [
|
||||
'post_icons'
|
||||
];
|
||||
$page_cfg['canonical_link'] = true;
|
||||
|
||||
// Show last topic
|
||||
$show_last_topic = true;
|
||||
|
|
|
@ -2236,3 +2236,43 @@ function infoByIP(string $ipAddress, int $port = 0): array
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates canonical url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getCanonicalUrl(): string
|
||||
{
|
||||
$fullUrl = rtrim(FULL_URL, '/');
|
||||
$script = $_SERVER['SCRIPT_NAME'];
|
||||
|
||||
$allowedParams = [
|
||||
POST_CAT_URL,
|
||||
POST_FORUM_URL,
|
||||
POST_GROUPS_URL,
|
||||
POST_POST_URL,
|
||||
POST_TOPIC_URL,
|
||||
POST_USERS_URL,
|
||||
'sort',
|
||||
'start',
|
||||
'order'
|
||||
];
|
||||
|
||||
$params = [];
|
||||
foreach ($allowedParams as $key) {
|
||||
if (isset($_GET[$key])) {
|
||||
$params[$key] = $_GET[$key];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params)) {
|
||||
ksort($params);
|
||||
$queryString = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
|
||||
$url = $fullUrl . $script . "?$queryString";
|
||||
} else {
|
||||
$url = $fullUrl . $script;
|
||||
}
|
||||
|
||||
return htmlCHR($url);
|
||||
}
|
||||
|
|
|
@ -123,6 +123,9 @@ $template->assign_vars([
|
|||
|
||||
'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']),
|
||||
'ALLOW_ROBOTS' => !$bb_cfg['board_disable'] && (!isset($page_cfg['allow_robots']) || $page_cfg['allow_robots'] === true),
|
||||
'META_CANONICAL' => (isset($page_cfg['canonical_link']) && $page_cfg['canonical_link'] === true)
|
||||
? getCanonicalUrl()
|
||||
: ((isset($page_cfg['canonical_link']) && is_string($page_cfg['canonical_link'])) ? $page_cfg['canonical_link'] : false),
|
||||
'META_DESCRIPTION' => $page_cfg['meta_description'] ?? '',
|
||||
|
||||
'SITENAME' => $bb_cfg['sitename'],
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
<!-- ELSE -->
|
||||
<meta name="robots" content="none">
|
||||
<!-- ENDIF -->
|
||||
<!-- IF META_CANONICAL -->
|
||||
<link rel="canonical" href="{META_CANONICAL}"/>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF META_PREV_PAGE -->
|
||||
<link rel="prev" href="{META_PREV_PAGE}">
|
||||
<!-- ENDIF / META_PREV_PAGE -->
|
||||
|
|
|
@ -12,6 +12,7 @@ define('BB_SCRIPT', 'forum');
|
|||
require __DIR__ . '/common.php';
|
||||
|
||||
$page_cfg['include_bbcode_js'] = true;
|
||||
$page_cfg['canonical_link'] = true;
|
||||
|
||||
$show_last_topic = true;
|
||||
$last_topic_max_len = 40;
|
||||
|
|
|
@ -22,6 +22,7 @@ $page_cfg['load_tpl_vars'] = [
|
|||
'post_icons',
|
||||
'topic_icons'
|
||||
];
|
||||
$page_cfg['canonical_link'] = true;
|
||||
|
||||
$newest = $next_topic_id = 0;
|
||||
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue