Make google happy and remove "duplicate content" despite canonical link

This commit is contained in:
2022-12-28 19:40:56 +01:00
parent aae719d025
commit 2976176ecb
10 changed files with 1192 additions and 1198 deletions

View File

@ -103,8 +103,8 @@ function send_html(): void
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 '<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.php" title="'._('Onion link list').'"/>';
echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '">';
echo '<link rel="alternate" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '" hreflang="x-default">';
echo '<link rel="canonical" href="' . CANONICAL_URL . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '">';
echo '<link rel="alternate" href="' . CANONICAL_URL . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '" hreflang="x-default">';
alt_links();
echo '<style>'.$style.'</style>';
echo '<base target="_blank">';
@ -115,7 +115,7 @@ function send_html(): void
}
echo '<p>'._('I\'m not responsible for any content of websites linked here. 99% of darkweb sites selling anything are scams. Be careful and use your brain. I regularly receive E-Mails from people that were desperate to make money and fell for scammers, don\'t be one of them!').'</p>';
//update onions description form
echo '<div class="table" id="edit-search"><div class="row"><div class="col"><form action="'.$_SERVER['SCRIPT_NAME'].'" target="_self" method="POST">';
echo '<div class="table" id="edit-search"><div class="row"><div class="col"><form target="_self" method="POST">';
echo '<input type="hidden" name="pg" value="'.htmlspecialchars($_REQUEST['newpg']).'">';
echo '<input type="hidden" name="lang" value="'.$language.'">';
echo '<p><label>'._('Onion address:').'<br><input name="addr" size="30" placeholder="http://'.$_SERVER['HTTP_HOST'].'" value="';
@ -150,7 +150,7 @@ function send_html(): void
send_captcha();
echo '<input type="submit" name="action" value="'._('Update').'"></form></div>';
//search from
echo '<div class="col"><form action="'.$_SERVER['SCRIPT_NAME'].'" target="_self" method="post" role="search">';
echo '<div class="col"><form target="_self" method="post" role="search">';
echo '<input type="hidden" name="pg" value="'.htmlspecialchars($_REQUEST['newpg']).'">';
echo '<input type="hidden" name="lang" value="'.$language.'">';
echo '<p><label>'._('Search:').' <br><input name="q" size="30" placeholder="'._('Search term').'" value="';

View File

@ -8,5 +8,5 @@ header('Content-Type: application/opensearchdescription+xml');
<Contact>daniel@danwin1210.de</Contact>
<Developer>Daniel Winzen</Developer>
<Image width="192" height="192" type="image/gif"><?php echo CANONICAL_URL; ?>/favicon.ico</Image>
<Url type="text/html" method="get" template="<?php echo CANONICAL_URL; ?>/onions.php?q={searchTerms}" />
<Url type="text/html" method="get" template="<?php echo CANONICAL_URL; ?>/?q={searchTerms}" />
</OpenSearchDescription>

View File

@ -8,25 +8,25 @@ try{
}
$links = [];
$links []= ['loc' => CANONICAL_URL . '/test.php', 'changefreq' => 'weekly', 'priority' => '0.8'];
$links []= ['loc' => CANONICAL_URL . '/onions.php', 'changefreq' => 'daily', 'priority' => '1'];
$links []= ['loc' => CANONICAL_URL . '/onions.php?format=json', 'changefreq' => 'daily', 'priority' => '0.2'];
$links []= ['loc' => CANONICAL_URL . '/onions.php?format=text', 'changefreq' => 'daily', 'priority' => '0.2'];
$links []= ['loc' => CANONICAL_URL . '/', 'changefreq' => 'daily', 'priority' => '1'];
$links []= ['loc' => CANONICAL_URL . '/?format=json', 'changefreq' => 'daily', 'priority' => '0.2'];
$links []= ['loc' => CANONICAL_URL . '/?format=text', 'changefreq' => 'daily', 'priority' => '0.2'];
$admin_approval = '';
if(REQUIRE_APPROVAL){
$admin_approval = PREFIX . 'onions.approved = 1 AND';
}
foreach (LANGUAGES as $lang_code => $data){
$links []= ['loc' => CANONICAL_URL . "/test.php?lang=$lang_code", 'changefreq' => 'weekly', 'priority' => '0.4'];
$links []= ['loc' => CANONICAL_URL . "/onions.php?lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.5'];
$links []= ['loc' => CANONICAL_URL . "/?lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.5'];
$stmt=$db->prepare('SELECT COUNT(*) FROM ' . PREFIX . "onions WHERE $admin_approval category=? AND address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800;');
foreach($categories as $cat => $name){
$links []= ['loc' => CANONICAL_URL . "/onions.php?cat=$cat&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3'];
$links []= ['loc' => CANONICAL_URL . "/?cat=$cat&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3'];
$stmt->execute([$cat]);
$num=$stmt->fetch(PDO::FETCH_NUM);
$pages=ceil($num[0]/PER_PAGE);
if($pages > 1) {
while ( $pages > -1 ) {
$links [] = [ 'loc' => CANONICAL_URL . "/onions.php?cat=$cat&pg=$pages&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3' ];
$links [] = [ 'loc' => CANONICAL_URL . "/?cat=$cat&pg=$pages&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3' ];
--$pages;
}
}
@ -38,7 +38,7 @@ foreach (LANGUAGES as $lang_code => $data){
];
$cat=count($categories);
foreach($special as $query){
$links []= ['loc' => CANONICAL_URL . "/onions.php?cat=$cat&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3'];
$links []= ['loc' => CANONICAL_URL . "/?cat=$cat&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3'];
if($cat===count($categories)+1){
$num[0]=PER_PAGE;
}else{
@ -47,13 +47,13 @@ foreach (LANGUAGES as $lang_code => $data){
$pages=ceil($num[0]/PER_PAGE);
if($pages > 1) {
while ( $pages > -1 ) {
$links [] = [ 'loc' => CANONICAL_URL . "/onions.php?cat=$cat&pg=$pages&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3' ];
$links [] = [ 'loc' => CANONICAL_URL . "/?cat=$cat&pg=$pages&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3' ];
--$pages;
}
}
++$cat;
}
$links []= ['loc' => CANONICAL_URL . "/onions.php?cat=$cat&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3'];
$links []= ['loc' => CANONICAL_URL . "/?cat=$cat&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3'];
}
$dom = new DOMDocument('1.0', 'UTF-8');
try {