mirror of
https://github.com/torrentpier/torrentpier
synced 2025-07-05 12:36:12 -07:00
revert: Added IndexNow
protocol support 🤖
This commit is contained in:
parent
6440162187
commit
1b288a96e4
7 changed files with 3 additions and 155 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,7 +4,6 @@
|
|||
|
||||
### TorrentPier ###
|
||||
*.log
|
||||
/*.txt
|
||||
install.php_*
|
||||
composer-setup.php
|
||||
.env
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
"egulias/email-validator": "^4.0.1",
|
||||
"filp/whoops": "^2.15",
|
||||
"z4kn4fein/php-semver": "^v3.0.0",
|
||||
"nemorize/indexnow": "^0.0.1",
|
||||
"gigablah/sphinxphp": "2.0.8",
|
||||
"google/recaptcha": "^1.3",
|
||||
"jacklul/monolog-telegram": "^3.1",
|
||||
|
|
48
composer.lock
generated
48
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c1e345a7abe58feb13d951acfd499e95",
|
||||
"content-hash": "ed0c6f72e121f5b35712c0855bc64a82",
|
||||
"packages": [
|
||||
{
|
||||
"name": "arokettu/bencode",
|
||||
|
@ -2057,48 +2057,6 @@
|
|||
],
|
||||
"time": "2025-03-24T10:02:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nemorize/indexnow",
|
||||
"version": "0.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nemorize/php-indexnow.git",
|
||||
"reference": "7602a8ae1de0cf1dd11692a7627f10111c55731a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nemorize/php-indexnow/zipball/7602a8ae1de0cf1dd11692a7627f10111c55731a",
|
||||
"reference": "7602a8ae1de0cf1dd11692a7627f10111c55731a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^7.7",
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Nemorize\\Indexnow\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ji Yong, Kim",
|
||||
"email": "nemo@qroffle.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP library for submitting website URLs using IndexNow to search engines.",
|
||||
"support": {
|
||||
"issues": "https://github.com/nemorize/php-indexnow/issues",
|
||||
"source": "https://github.com/nemorize/php-indexnow/tree/0.0.1"
|
||||
},
|
||||
"abandoned": true,
|
||||
"time": "2023-07-31T17:08:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/iter",
|
||||
"version": "v2.4.1",
|
||||
|
@ -3854,6 +3812,6 @@
|
|||
"platform": {
|
||||
"php": "^8.1 | ^8.2 | ^8.3 | ^8.4"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
|
|
@ -144,12 +144,6 @@ $bb_cfg['torr_server'] = [
|
|||
'disable_for_guest' => true
|
||||
];
|
||||
|
||||
// IndexNow settings
|
||||
$bb_cfg['indexnow_settings'] = [
|
||||
'enabled' => false,
|
||||
'host' => 'bing', // Available: yandex, bing, seznam, naver
|
||||
];
|
||||
|
||||
// FAQ url help link
|
||||
$bb_cfg['how_to_download_url_help'] = 'viewtopic.php?t=1'; // How to download?
|
||||
$bb_cfg['what_is_torrent_url_help'] = 'viewtopic.php?t=2'; // What is a torrent?
|
||||
|
|
|
@ -64,14 +64,5 @@ if (empty($bb_cfg['tp_instance_hash']) || ($bb_cfg['tp_instance_hash'] !== hash(
|
|||
bb_update_config(['tp_instance_hash' => hash('xxh128', FULL_URL)]);
|
||||
}
|
||||
|
||||
// Generate IndexNow key
|
||||
if ($bb_cfg['indexnow_settings']['enabled'] && !is_file(BB_ROOT . $bb_cfg['indexnow_key'] . \TorrentPier\IndexNow::$keyFileExtension)) {
|
||||
$randomIndexNowKey = empty($bb_cfg['indexnow_key']) ? make_rand_str(rand(64, 128)) : $bb_cfg['indexnow_key'];
|
||||
if ($bb_cfg['indexnow_key'] !== $randomIndexNowKey) {
|
||||
bb_update_config(['indexnow_key' => $randomIndexNowKey]);
|
||||
}
|
||||
file_write($randomIndexNowKey, (BB_ROOT . $randomIndexNowKey . \TorrentPier\IndexNow::$keyFileExtension));
|
||||
}
|
||||
|
||||
// Check for updates
|
||||
$datastore->update('check_updates');
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* TorrentPier – Bull-powered BitTorrent tracker engine
|
||||
*
|
||||
* @copyright Copyright (c) 2005-2025 TorrentPier (https://torrentpier.com)
|
||||
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
|
||||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||||
*/
|
||||
|
||||
namespace TorrentPier;
|
||||
|
||||
use Nemorize\Indexnow\Exceptions\IndexnowException;
|
||||
|
||||
/**
|
||||
* Class IndexNow
|
||||
* @package TorrentPier
|
||||
*/
|
||||
class IndexNow
|
||||
{
|
||||
/**
|
||||
* IndexNow instance
|
||||
*
|
||||
* @var \Nemorize\Indexnow\Indexnow
|
||||
*/
|
||||
private \Nemorize\Indexnow\Indexnow $indexNow;
|
||||
|
||||
/**
|
||||
* IndexNow Key-file extension
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static string $keyFileExtension = '.txt';
|
||||
|
||||
/**
|
||||
* Log filename
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static string $logFile = 'index_now';
|
||||
|
||||
/**
|
||||
* Available hosts
|
||||
*
|
||||
* @var array|string[]
|
||||
*/
|
||||
public array $hosts = [
|
||||
'yandex' => 'yandex.com',
|
||||
'bing' => 'bing.com',
|
||||
'seznam' => 'search.seznam.cz',
|
||||
'naver' => 'searchadvisor.naver.com'
|
||||
];
|
||||
|
||||
/**
|
||||
* IndexNow constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
$this->indexNow = new \Nemorize\Indexnow\Indexnow();
|
||||
$this->indexNow->setKey($bb_cfg['indexnow_key']);
|
||||
if (in_array($bb_cfg['indexnow_settings']['host'], array_keys($this->hosts))) {
|
||||
$this->indexNow->setHost($this->hosts[$bb_cfg['indexnow_settings']['host']]);
|
||||
} else {
|
||||
bb_log("IndexNow (ERROR): Invalid host: {$bb_cfg['indexnow_settings']['host']}\n", self::$logFile);
|
||||
bb_die('Invalid host: ' . $bb_cfg['indexnow_settings']['host']);
|
||||
}
|
||||
$this->indexNow->setKeyLocation(FULL_URL . $bb_cfg['indexnow_key'] . self::$keyFileExtension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit page to IndexNow
|
||||
*
|
||||
* @param string $url
|
||||
* @return void
|
||||
*/
|
||||
public function submit(string $url): void
|
||||
{
|
||||
try {
|
||||
$this->indexNow->submit($url);
|
||||
} catch (IndexnowException $e) {
|
||||
bb_log("IndexNow (ERROR) [$url]: Message: {$e->getMessage()}\n", self::$logFile);
|
||||
bb_die($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@
|
|||
namespace TorrentPier\Legacy;
|
||||
|
||||
use TorrentPier\Emailer;
|
||||
use TorrentPier\IndexNow;
|
||||
use TorrentPier\Legacy\Admin\Common;
|
||||
use TorrentPier\Validate;
|
||||
|
||||
|
@ -221,12 +220,6 @@ class Post
|
|||
}
|
||||
}
|
||||
|
||||
// Send IndexNow
|
||||
if ($bb_cfg['indexnow_settings']['enabled'] && ($mode === 'newtopic' || $mode === 'editpost')) {
|
||||
$indexNow = new IndexNow();
|
||||
$indexNow->submit(FULL_URL . POST_URL . "$post_id#$post_id");
|
||||
}
|
||||
|
||||
meta_refresh(POST_URL . "$post_id#$post_id");
|
||||
set_die_append_msg($forum_id, $topic_id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue