Set canonical tag only with whitelisted parameters

This commit is contained in:
Daniel Winzen
2020-11-13 09:21:26 +01:00
parent b9b5b6092f
commit 725e660ac6
2 changed files with 16 additions and 2 deletions

View File

@ -55,6 +55,16 @@ function send_html(){
$I['lastadded']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing)', $I['lastadded']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing)',
$I['offline']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff>604800' $I['offline']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff>604800'
]; ];
$canonical_query = [];
if(!empty($_REQUEST['cat'])) {
$canonical_query['cat'] = $_REQUEST['cat'];
}
if(!empty($_REQUEST['pg'])) {
$canonical_query['pg'] = $_REQUEST['pg'];
}
if(!empty($_REQUEST['lang'])) {
$canonical_query['lang'] = $_REQUEST['lang'];
}
if(!isset($_REQUEST['pg'])){ if(!isset($_REQUEST['pg'])){
$_REQUEST['pg']=1; $_REQUEST['pg']=1;
}else{ }else{
@ -111,7 +121,7 @@ function send_html(){
echo '<meta name="author" content="Daniel Winzen">'; echo '<meta name="author" content="Daniel Winzen">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">'; echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '<meta name="description" content="Huge link list of Tor hidden service onions. All the darknet links you need in one place.">'; echo '<meta name="description" content="Huge link list of Tor hidden service onions. All the darknet links you need in one place.">';
echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']) . '">'; echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '">';
echo '<style type="text/css">'.$style.'</style>'; echo '<style type="text/css">'.$style.'</style>';
echo '<base rel="noopener" target="_blank">'; echo '<base rel="noopener" target="_blank">';
echo '</head><body><main>'; echo '</head><body><main>';

View File

@ -2,13 +2,17 @@
require_once(__DIR__.'/../common_config.php'); require_once(__DIR__.'/../common_config.php');
$style = '.red{color:red}.green{color:green}.software-link{text-align:center;font-size:small}.list{padding:0;}.list li{display:inline-block;padding:0.35em}'; $style = '.red{color:red}.green{color:green}.software-link{text-align:center;font-size:small}.list{padding:0;}.list li{display:inline-block;padding:0.35em}';
send_headers([$style]); send_headers([$style]);
$canonical_query = [];
if(!empty($_REQUEST['lang'])) {
$canonical_query['lang'] = $_REQUEST['lang'];
}
echo '<!DOCTYPE html><html lang="'.$language.'"><head>'; echo '<!DOCTYPE html><html lang="'.$language.'"><head>';
echo "<title>$I[testtitle]</title>"; echo "<title>$I[testtitle]</title>";
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
echo '<meta name="author" content="Daniel Winzen">'; echo '<meta name="author" content="Daniel Winzen">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">'; echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '<meta name="description" content="Test whether a Tor hidden service onion is online or offline">'; echo '<meta name="description" content="Test whether a Tor hidden service onion is online or offline">';
echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . '">'; echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '">';
echo '<style type="text/css">'.$style.'</style>'; echo '<style type="text/css">'.$style.'</style>';
echo '</head><body><main>'; echo '</head><body><main>';
echo "<h1>$I[testtitle]</h1>"; echo "<h1>$I[testtitle]</h1>";