Мультитрекер (парсер числа внешних пиров)

Мультитрекер (парсер числа внешних пиров) v2.2.1

lexXxa

Пользователь
не могу понять в чем проблема логи чистые Ошибка в: ajax.php
500 Internal Server Error

define('BB_SCRIPT', 'ajax');
define('IN_AJAX', true);

require __DIR__ . '/common.php';

$ajax = new TorrentPier\Legacy\Ajax();

$ajax->init();

// Init userdata
$user->session_start();

// Exit if board is disabled via ON/OFF trigger or by admin
if ($ajax->action != 'manage_admin') {
if ($bb_cfg['board_disable']) {
$ajax->ajax_die($lang['BOARD_DISABLE']);
} elseif (file_exists(BB_DISABLED)) {
$ajax->ajax_die($lang['BOARD_DISABLE_CRON']);
}
}

// Load actions required modules
switch ($ajax->action) {
case 'view_post':
require INC_DIR . '/bbcode.php';
break;

case 'update_peers':
require(BB_ROOT .'mult/config.php');
require(BB_ROOT .'mult/func.php');
require(BB_ROOT .'mult/class.remote.php');
require(BB_ROOT .'mult/class.fbenc.php');
require(BB_ROOT .'mult/class.bittorrent.php');
require(BB_ROOT .'mult/class.getpeers.php');
break;
case 'posts':
case 'post_mod_comment':
require INC_DIR . '/bbcode.php';
require INC_DIR . '/functions_post.php';
require INC_DIR . '/functions_admin.php';
break;

case 'view_torrent':
case 'mod_action':
case 'change_tor_status':
case 'change_torrent':
case 'gen_passkey':
require ATTACH_DIR . '/attachment_mod.php';
require INC_DIR . '/functions_torrent.php';
break;

case 'user_register':
require INC_DIR . '/functions_validate.php';
break;

case 'manage_user':
case 'manage_admin':
require INC_DIR . '/functions_admin.php';
break;

case 'group_membership':
case 'manage_group':
require INC_DIR . '/functions_group.php';
break;
}

// Position in $ajax->valid_actions['xxx']
define('AJAX_AUTH', 0); // 'guest', 'user', 'mod', 'admin', 'super_admin'

$ajax->exec();

/**
* @deprecated ajax_common
* Dirty class removed from here since 2.2.0
* To add new actions see at src/Legacy/Ajax.php
*/

class Ajax
{
public $request = [];
public $response = [];

public $valid_actions = [
// ACTION NAME AJAX_AUTH
'edit_user_profile' => ['admin'],
'change_user_rank' => ['admin'],
'change_user_opt' => ['admin'],
'manage_user' => ['admin'],
'manage_admin' => ['admin'],
'sitemap' => ['admin'],

'mod_action' => ['mod'],
'topic_tpl' => ['mod'],
'group_membership' => ['mod'],
'post_mod_comment' => ['mod'],
'update_peers' => ['mod'],

'avatar' => ['user'],
'gen_passkey' => ['user'],
'change_torrent' => ['user'],
'change_tor_status' => ['user'],
'manage_group' => ['user'],

'view_post' => ['guest'],
'view_torrent' => ['guest'],
'user_register' => ['guest'],
'posts' => ['guest'],
'index_data' => ['guest'],


];

public $action;

/**
* Constructor
*/
public function __construct()
{
ob_start([&$this, 'ob_handler']);
header('Content-Type: text/plain');
}

/**
* Perform action
*/
public function exec()
{
global $lang;

// Exit if we already have errors
if (!empty($this->response['error_code'])) {
$this->send();
}

// Check that requested action is valid
$action = $this->action;

if (!$action || !is_string($action)) {
$this->ajax_die('no action specified');
} elseif (!$action_params =& $this->valid_actions[$action]) {
$this->ajax_die('invalid action: ' . $action);
}

// Auth check
switch ($action_params[AJAX_AUTH]) {
// GUEST
case 'guest':
break;

// USER
case 'user':
if (IS_GUEST) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
break;

// MOD
case 'mod':
if (!IS_AM) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
$this->check_admin_session();
break;

// ADMIN
case 'admin':
if (!IS_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_ADMIN']);
}
$this->check_admin_session();
break;

// SUPER_ADMIN
case 'super_admin':
if (!IS_SUPER_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$this->check_admin_session();
break;

default:
trigger_error("invalid auth type for $action", E_USER_ERROR);
}

// Run action
$this->$action();

// Send output
$this->send();
}

/**
* Exit on error
*
* @param $error_msg
* @param int $error_code
*/
public function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_ERROR)
{
$this->response['error_code'] = $error_code;
$this->response['error_msg'] = $error_msg;

$this->send();
}

/**
* Initialization
*/
public function init()
{
$this->request = $_POST;
$this->action =& $this->request['action'];
}

/**
* Send data
*/
public function send()
{
$this->response['action'] = $this->action;

if (DBG_USER && SQL_DEBUG && !empty($_COOKIE['sql_log'])) {
$this->response['sql_log'] = get_sql_log();
}

// sending output will be handled by $this->ob_handler()
exit();
}

/**
* OB Handler
*
* @param $contents
* @return string
*/
public function ob_handler($contents)
{
if (DBG_USER) {
if ($contents) {
$this->response['raw_output'] = $contents;
}
}

$response_js = json_encode($this->response);

if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000) {
header('Content-Encoding: gzip');
$response_js = gzencode($response_js, 1);
}
}

return $response_js;
}

/**
* Admin session
*/
public function check_admin_session()
{
global $user;

if (!$user->data['session_admin']) {
if (empty($this->request['user_password'])) {
$this->prompt_for_password();
} else {
$login_args = [
'login_username' => $user->data['username'],
'login_password' => $_POST['user_password'],
];
if (!$user->login($login_args, true)) {
$this->ajax_die('Wrong password');
}
}
}
}

/**
* Prompt for password
*/
public function prompt_for_password()
{
$this->response['prompt_password'] = 1;
$this->send();
}

/**
* Prompt for confirmation
*
* @param string $confirm_msg
*/
public function prompt_for_confirm($confirm_msg)
{
if (empty($confirm_msg)) {
$this->ajax_die('false');
}

$this->response['prompt_confirm'] = 1;
$this->response['confirm_msg'] = $confirm_msg;
$this->send();
}

/**
* Verify mod rights
*
* @param integer $forum_id
*/
public function verify_mod_rights($forum_id)
{
global $userdata, $lang;

$is_auth = auth(AUTH_MOD, $forum_id, $userdata);

if (!$is_auth['auth_mod']) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
}

public function edit_user_profile()
{
require AJAX_DIR . '/edit_user_profile.php';
}

public function change_user_rank()
{
require AJAX_DIR . '/change_user_rank.php';
}

public function change_user_opt()
{
require AJAX_DIR . '/change_user_opt.php';
}

public function gen_passkey()
{
require AJAX_DIR . '/gen_passkey.php';
}

public function group_membership()
{
require AJAX_DIR . '/group_membership.php';
}

public function manage_group()
{
require AJAX_DIR . '/edit_group_profile.php';
}

public function post_mod_comment()
{
require AJAX_DIR . '/post_mod_comment.php';
}

public function view_post()
{
require AJAX_DIR . '/view_post.php';
}

public function change_tor_status()
{
require AJAX_DIR . '/change_tor_status.php';
}

public function change_torrent()
{
require AJAX_DIR . '/change_torrent.php';
}

public function view_torrent()
{
require AJAX_DIR . '/view_torrent.php';
}

public function user_register()
{
require AJAX_DIR . '/user_register.php';
}

public function mod_action()
{
require AJAX_DIR . '/mod_action.php';
}

public function posts()
{
require AJAX_DIR . '/posts.php';
}

public function manage_user()
{
require AJAX_DIR . '/manage_user.php';
}

public function manage_admin()
{
require AJAX_DIR . '/manage_admin.php';
}

public function topic_tpl()
{
require AJAX_DIR . '/topic_tpl.php';
}

public function index_data()
{
require AJAX_DIR . '/index_data.php';
}

public function avatar()
{
require AJAX_DIR . '/avatar.php';
}

public function sitemap()
{
require AJAX_DIR . '/sitemap.php';
}

public function update_peers()
{
global $db, $cfg_ann, $lang;
$seed = $leech = 0;
$topic_id = (int) $this->request['topic_id'];
$row = DB()->fetch_row("SELECT info_hash FROM ".BB_BT_TORRENTS." WHERE topic_id = ".$topic_id." LIMIT 1");
if($row && $info_hash = $row['info_hash'])
{
$gp = new getpeers();
$data = $gp->get_peers(1, serialize($cfg_ann), bin2hex($info_hash), false);
foreach($data['peers'] as $announce)
{
$seed = (int) $seed + $announce[0];
$leech = (int) $leech + $announce[1];
}
//DB()->query("UPDATE ".BB_BT_TORRENTS." SET last_update = ".$data['last_update'].", ext_seeder = ".$seed.", ext_leecher = ".$leech." WHERE info_hash = '".DB()->escape($info_hash)."'");
DB()->query("UPDATE ".BB_BT_TORRENTS." SET last_update = ".$data['last_update'].", ext_seeder = ".$seed.", ext_leecher = ".$leech." WHERE topic_id = $topic_id");
$html = '<div class="mrg_4 pad_4">';
$html .= '<span class="seed">'. $lang['SEEDERS'] .':&nbsp; <b>'. $seed .'</b> &nbsp;[&nbsp; 0 KB/s &nbsp;]</span> &nbsp;';
$html .= '<span class="leech">'. $lang['LEECHERS'] .':&nbsp; <b>'. $leech .'</b> &nbsp;[&nbsp; 0 KB/s &nbsp;]</span> &nbsp;';
$html .= '</div>';
}
$this->response['html'] = $html;
$this->response['topic_id'] = $topic_id;
}


}
 
Последнее редактирование:

Virtuoz

Пользователь
не могу понять в чем проблема логи чистые Ошибка в: ajax.php
500 Internal Server Error

define('BB_SCRIPT', 'ajax');
define('IN_AJAX', true);

require __DIR__ . '/common.php';

$ajax = new TorrentPier\Legacy\Ajax();

$ajax->init();

// Init userdata
$user->session_start();

// Exit if board is disabled via ON/OFF trigger or by admin
if ($ajax->action != 'manage_admin') {
if ($bb_cfg['board_disable']) {
$ajax->ajax_die($lang['BOARD_DISABLE']);
} elseif (file_exists(BB_DISABLED)) {
$ajax->ajax_die($lang['BOARD_DISABLE_CRON']);
}
}

// Load actions required modules
switch ($ajax->action) {
case 'view_post':
require INC_DIR . '/bbcode.php';
break;
case 'update_peers':
require INC_DIR . '/mult/config.php';
require INC_DIR . '/mult/func.php';
require INC_DIR . '/mult/class.remote.php';
require INC_DIR . '/mult/class.fbenc.php';
require INC_DIR . '/mult/class.bittorrent.php';
require INC_DIR . '/mult/class.getpeers.php';
break;

case 'posts':
case 'post_mod_comment':
require INC_DIR . '/bbcode.php';
require INC_DIR . '/functions_post.php';
require INC_DIR . '/functions_admin.php';
break;

case 'view_torrent':
case 'mod_action':
case 'change_tor_status':
case 'change_torrent':
case 'gen_passkey':
require ATTACH_DIR . '/attachment_mod.php';
require INC_DIR . '/functions_torrent.php';
break;

case 'user_register':
require INC_DIR . '/functions_validate.php';
break;

case 'manage_user':
case 'manage_admin':
require INC_DIR . '/functions_admin.php';
break;

case 'group_membership':
case 'manage_group':
require INC_DIR . '/functions_group.php';
break;
}

// Position in $ajax->valid_actions['xxx']
define('AJAX_AUTH', 0); // 'guest', 'user', 'mod', 'admin', 'super_admin'

$ajax->exec();

/**
* @deprecated ajax_common
* Dirty class removed from here since 2.2.0
* To add new actions see at src/Legacy/Ajax.php
*/

class Ajax
{
public $request = [];
public $response = [];

public $valid_actions = [
// ACTION NAME AJAX_AUTH
'edit_user_profile' => ['admin'],
'change_user_rank' => ['admin'],
'change_user_opt' => ['admin'],
'manage_user' => ['admin'],
'manage_admin' => ['admin'],
'sitemap' => ['admin'],

'mod_action' => ['mod'],
'topic_tpl' => ['mod'],
'group_membership' => ['mod'],
'post_mod_comment' => ['mod'],
'update_peers' => ['mod'],

'avatar' => ['user'],
'gen_passkey' => ['user'],
'change_torrent' => ['user'],
'change_tor_status' => ['user'],
'manage_group' => ['user'],

'view_post' => ['guest'],
'view_torrent' => ['guest'],
'user_register' => ['guest'],
'posts' => ['guest'],
'index_data' => ['guest'],


];

public $action;

/**
* Constructor
*/
public function __construct()
{
ob_start([&$this, 'ob_handler']);
header('Content-Type: text/plain');
}

/**
* Perform action
*/
public function exec()
{
global $lang;

// Exit if we already have errors
if (!empty($this->response['error_code'])) {
$this->send();
}

// Check that requested action is valid
$action = $this->action;

if (!$action || !is_string($action)) {
$this->ajax_die('no action specified');
} elseif (!$action_params =& $this->valid_actions[$action]) {
$this->ajax_die('invalid action: ' . $action);
}

// Auth check
switch ($action_params[AJAX_AUTH]) {
// GUEST
case 'guest':
break;

// USER
case 'user':
if (IS_GUEST) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
break;

// MOD
case 'mod':
if (!IS_AM) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
$this->check_admin_session();
break;

// ADMIN
case 'admin':
if (!IS_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_ADMIN']);
}
$this->check_admin_session();
break;

// SUPER_ADMIN
case 'super_admin':
if (!IS_SUPER_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$this->check_admin_session();
break;

default:
trigger_error("invalid auth type for $action", E_USER_ERROR);
}

// Run action
$this->$action();

// Send output
$this->send();
}

/**
* Exit on error
*
* @param $error_msg
* @param int $error_code
*/
public function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_ERROR)
{
$this->response['error_code'] = $error_code;
$this->response['error_msg'] = $error_msg;

$this->send();
}

/**
* Initialization
*/
public function init()
{
$this->request = $_POST;
$this->action =& $this->request['action'];
}

/**
* Send data
*/
public function send()
{
$this->response['action'] = $this->action;

if (DBG_USER && SQL_DEBUG && !empty($_COOKIE['sql_log'])) {
$this->response['sql_log'] = get_sql_log();
}

// sending output will be handled by $this->ob_handler()
exit();
}

/**
* OB Handler
*
* @param $contents
* @return string
*/
public function ob_handler($contents)
{
if (DBG_USER) {
if ($contents) {
$this->response['raw_output'] = $contents;
}
}

$response_js = json_encode($this->response);

if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) {
if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000) {
header('Content-Encoding: gzip');
$response_js = gzencode($response_js, 1);
}
}

return $response_js;
}

/**
* Admin session
*/
public function check_admin_session()
{
global $user;

if (!$user->data['session_admin']) {
if (empty($this->request['user_password'])) {
$this->prompt_for_password();
} else {
$login_args = [
'login_username' => $user->data['username'],
'login_password' => $_POST['user_password'],
];
if (!$user->login($login_args, true)) {
$this->ajax_die('Wrong password');
}
}
}
}

/**
* Prompt for password
*/
public function prompt_for_password()
{
$this->response['prompt_password'] = 1;
$this->send();
}

/**
* Prompt for confirmation
*
* @param string $confirm_msg
*/
public function prompt_for_confirm($confirm_msg)
{
if (empty($confirm_msg)) {
$this->ajax_die('false');
}

$this->response['prompt_confirm'] = 1;
$this->response['confirm_msg'] = $confirm_msg;
$this->send();
}

/**
* Verify mod rights
*
* @param integer $forum_id
*/
public function verify_mod_rights($forum_id)
{
global $userdata, $lang;

$is_auth = auth(AUTH_MOD, $forum_id, $userdata);

if (!$is_auth['auth_mod']) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
}

public function edit_user_profile()
{
require AJAX_DIR . '/edit_user_profile.php';
}

public function change_user_rank()
{
require AJAX_DIR . '/change_user_rank.php';
}

public function change_user_opt()
{
require AJAX_DIR . '/change_user_opt.php';
}

public function gen_passkey()
{
require AJAX_DIR . '/gen_passkey.php';
}

public function group_membership()
{
require AJAX_DIR . '/group_membership.php';
}

public function manage_group()
{
require AJAX_DIR . '/edit_group_profile.php';
}

public function post_mod_comment()
{
require AJAX_DIR . '/post_mod_comment.php';
}

public function view_post()
{
require AJAX_DIR . '/view_post.php';
}

public function change_tor_status()
{
require AJAX_DIR . '/change_tor_status.php';
}

public function change_torrent()
{
require AJAX_DIR . '/change_torrent.php';
}

public function view_torrent()
{
require AJAX_DIR . '/view_torrent.php';
}

public function user_register()
{
require AJAX_DIR . '/user_register.php';
}

public function mod_action()
{
require AJAX_DIR . '/mod_action.php';
}

public function posts()
{
require AJAX_DIR . '/posts.php';
}

public function manage_user()
{
require AJAX_DIR . '/manage_user.php';
}

public function manage_admin()
{
require AJAX_DIR . '/manage_admin.php';
}

public function topic_tpl()
{
require AJAX_DIR . '/topic_tpl.php';
}

public function index_data()
{
require AJAX_DIR . '/index_data.php';
}

public function avatar()
{
require AJAX_DIR . '/avatar.php';
}

public function sitemap()
{
require AJAX_DIR . '/sitemap.php';
}

public function update_peers()
{
global $db, $cfg_ann, $lang;
$seed = $leech = 0;
$topic_id = (int) $this->request['topic_id'];
$row = DB()->fetch_row("SELECT info_hash FROM ".BB_BT_TORRENTS." WHERE topic_id = ".$topic_id." LIMIT 1");
if($row && $info_hash = $row['info_hash'])
{
$gp = new getpeers();
$data = $gp->get_peers(1, serialize($cfg_ann), bin2hex($info_hash), false);
foreach($data['peers'] as $announce)
{
$seed = (int) $seed + $announce[0];
$leech = (int) $leech + $announce[1];
}
//DB()->query("UPDATE ".BB_BT_TORRENTS." SET last_update = ".$data['last_update'].", ext_seeder = ".$seed.", ext_leecher = ".$leech." WHERE info_hash = '".DB()->escape($info_hash)."'");
DB()->query("UPDATE ".BB_BT_TORRENTS." SET last_update = ".$data['last_update'].", ext_seeder = ".$seed.", ext_leecher = ".$leech." WHERE topic_id = $topic_id");
$html = '<div class="mrg_4 pad_4">';
$html .= '<span class="seed">'. $lang['SEEDERS'] .':&nbsp; <b>'. $seed .'</b> &nbsp;[&nbsp; 0 KB/s &nbsp;]</span> &nbsp;';
$html .= '<span class="leech">'. $lang['LEECHERS'] .':&nbsp; <b>'. $leech .'</b> &nbsp;[&nbsp; 0 KB/s &nbsp;]</span> &nbsp;';
$html .= '</div>';
}
$this->response['html'] = $html;
$this->response['topic_id'] = $topic_id;
}


}

$gp = new getpeers(); заменить на $gp = new \getpeers();
 

ivangord

Пользователь
кто знает, как адаптировать код class getpeers под PHP 8.1+?
у меня вот такие логи
[2023-12-11T12:35:28.155454+03:00] TorrentPier.ERROR: Whoops\Exception\ErrorException: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file E:\OSPanel\domains\ibrary\includes\mult\class.getpeers.php on line 199
Stack trace:
1. Whoops\Exception\ErrorException->() E:\OSPanel\domains\ibrary\includes\mult\class.getpeers.php:199
2. Whoops\Run->handleError() E:\OSPanel\domains\library\includes\mult\class.getpeers.php:199
3. getpeers->parse_announcer() E:\OSPanel\domains\ibrary\includes\mult\class.getpeers.php:173
4. getpeers->get_peers() E:\OSPanel\domains\library\ajax\update_peers.php:12
5. require() E:\OSPanel\domains\src\Ajax.php:388
6. TorrentPier\Ajax->update_peers() E:\OSPanel\domains\src\Ajax.php:134
7. TorrentPier\Ajax->exec() E:\OSPanel\domains\ajax.php:47
[] []
 

belomaxorka

Разработчик
Администратор
кто знает, как адаптировать код class getpeers под PHP 8.1+?
у меня вот такие логи
[2023-12-11T12:35:28.155454+03:00] TorrentPier.ERROR: Whoops\Exception\ErrorException: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in file E:\OSPanel\domains\ibrary\includes\mult\class.getpeers.php on line 199
Stack trace:
1. Whoops\Exception\ErrorException->() E:\OSPanel\domains\ibrary\includes\mult\class.getpeers.php:199
2. Whoops\Run->handleError() E:\OSPanel\domains\library\includes\mult\class.getpeers.php:199
3. getpeers->parse_announcer() E:\OSPanel\domains\ibrary\includes\mult\class.getpeers.php:173
4. getpeers->get_peers() E:\OSPanel\domains\library\ajax\update_peers.php:12
5. require() E:\OSPanel\domains\src\Ajax.php:388
6. TorrentPier\Ajax->update_peers() E:\OSPanel\domains\src\Ajax.php:134
7. TorrentPier\Ajax->exec() E:\OSPanel\domains\ajax.php:47
[] []
Попробуйте вот так:
PHP:
return (int) (strlen(@$c['peers'] ?? 0) / 6);
 

ivangord

Пользователь
Уже пробовал... Теперь другая проблема:
[2023-12-11T19:11:22.765686+03:00] TorrentPier.ERROR: Whoops\Exception\ErrorException: Trying to access array offset on value of type int in file E:\OSPanel\domains\library\ajax\update_peers.php on line 25
Stack trace:
1. Whoops\Exception\ErrorException->() E:\OSPanel\domains\library\ajax\update_peers.php:25
2. Whoops\Run->handleError() E:\OSPanel\domains\library\ajax\update_peers.php:25
3. require() E:\OSPanel\domains\src\Ajax.php:388
4. TorrentPier\Ajax->update_peers() E:\OSPanel\domains\src\Ajax.php:134
5. TorrentPier\Ajax->exec() E:\OSPanel\domains\ajax.php:47
[] []
на линии 25
PHP:
  $seed = (int)$seed + $announce[0];
 

ivangord

Пользователь
ребят, кто пробовал уже ставить на актуальную версию движка? дело в том, что движок работает на php 8.1 + в БД были изменения. Соответственно запрос не рабочий
 
Сверху