mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
Продолжение синхронизации, повышение требований до php 5.5
Еще пачка файлов из старого репозитория Повышение требований к php (из-за ZF) Продолжение чисток
This commit is contained in:
parent
313356a9a4
commit
17c95ac01c
8 changed files with 73 additions and 516 deletions
|
@ -200,8 +200,6 @@ $tr_cfg = array(
|
||||||
|
|
||||||
$bb_cfg['show_dl_status_in_search'] = true;
|
$bb_cfg['show_dl_status_in_search'] = true;
|
||||||
$bb_cfg['show_dl_status_in_forum'] = true;
|
$bb_cfg['show_dl_status_in_forum'] = true;
|
||||||
|
|
||||||
$bb_cfg['show_tor_info_in_dl_list'] = true;
|
|
||||||
$bb_cfg['allow_dl_list_names_mode'] = true;
|
$bb_cfg['allow_dl_list_names_mode'] = true;
|
||||||
|
|
||||||
$bb_cfg['torrent_name_style'] = true; // use torrent name style [yoursite.com].txxx.torrent
|
$bb_cfg['torrent_name_style'] = true; // use torrent name style [yoursite.com].txxx.torrent
|
||||||
|
@ -542,14 +540,6 @@ $bb_cfg['allow_change'] = array(
|
||||||
|
|
||||||
define('GZIP_OUTPUT_ALLOWED', (extension_loaded('zlib') && !ini_get('zlib.output_compression')));
|
define('GZIP_OUTPUT_ALLOWED', (extension_loaded('zlib') && !ini_get('zlib.output_compression')));
|
||||||
|
|
||||||
$banned_user_agents = array(
|
|
||||||
// Download Master
|
|
||||||
# 'download',
|
|
||||||
# 'master',
|
|
||||||
// Others
|
|
||||||
# 'wget',
|
|
||||||
);
|
|
||||||
|
|
||||||
$bb_cfg['trash_forum_id'] = 0; // (int) 7
|
$bb_cfg['trash_forum_id'] = 0; // (int) 7
|
||||||
|
|
||||||
$bb_cfg['first_logon_redirect_url'] = 'index.php';
|
$bb_cfg['first_logon_redirect_url'] = 'index.php';
|
||||||
|
@ -578,8 +568,8 @@ $bb_cfg['attach'] = array(
|
||||||
'max_size' => 5*1024*1024, // максимальный размер файла в байтах
|
'max_size' => 5*1024*1024, // максимальный размер файла в байтах
|
||||||
);
|
);
|
||||||
|
|
||||||
$bb_cfg['tor_forums_allowed_ext'] = array('torrent', 'zip', 'rar'); // для разделов с раздачами
|
$bb_cfg['tor_forums_allowed_ext'] = ['torrent', 'zip', 'rar']; // для разделов с раздачами
|
||||||
$bb_cfg['gen_forums_allowed_ext'] = array('zip', 'rar'); // для обычных разделов
|
$bb_cfg['gen_forums_allowed_ext'] = ['torrent', 'zip', 'rar']; // для обычных разделов
|
||||||
|
|
||||||
// Avatars
|
// Avatars
|
||||||
$bb_cfg['avatars'] = array(
|
$bb_cfg['avatars'] = array(
|
||||||
|
|
|
@ -1209,23 +1209,6 @@ function show_bt_userdata ($user_id)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_attachments_dir ($cfg = null)
|
|
||||||
{
|
|
||||||
if (!$cfg AND !$cfg = $GLOBALS['attach_config'])
|
|
||||||
{
|
|
||||||
$cfg = bb_get_config(BB_ATTACH_CONFIG, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cfg['upload_dir'][0] == '/' || ($cfg['upload_dir'][0] != '/' && $cfg['upload_dir'][1] == ':'))
|
|
||||||
{
|
|
||||||
return $cfg['upload_dir'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BB_ROOT . $cfg['upload_dir'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function bb_get_config ($table, $from_db = false, $update_cache = true)
|
function bb_get_config ($table, $from_db = false, $update_cache = true)
|
||||||
{
|
{
|
||||||
if ($from_db OR !$cfg = CACHE('bb_config')->get("config_{$table}"))
|
if ($from_db OR !$cfg = CACHE('bb_config')->get("config_{$table}"))
|
||||||
|
@ -1927,7 +1910,7 @@ function cat_exists ($cat_id)
|
||||||
//
|
//
|
||||||
class log_action
|
class log_action
|
||||||
{
|
{
|
||||||
var $log_type = array(
|
var $log_type = [
|
||||||
# LOG_TYPE_NAME LOG_TYPE_ID
|
# LOG_TYPE_NAME LOG_TYPE_ID
|
||||||
'mod_topic_delete' => 1,
|
'mod_topic_delete' => 1,
|
||||||
'mod_topic_move' => 2,
|
'mod_topic_move' => 2,
|
||||||
|
@ -1938,8 +1921,15 @@ class log_action
|
||||||
'adm_user_delete' => 7,
|
'adm_user_delete' => 7,
|
||||||
'adm_user_ban' => 8,
|
'adm_user_ban' => 8,
|
||||||
'adm_user_unban' => 9,
|
'adm_user_unban' => 9,
|
||||||
);
|
'tor_status_changed' => 10,
|
||||||
var $log_type_select = array();
|
'att_delete' => 11,
|
||||||
|
'tor_unreg' => 12,
|
||||||
|
'tor_cphold_close' => 13,
|
||||||
|
'adm_ban_ip' => 14,
|
||||||
|
'adm_ban_email' => 15,
|
||||||
|
'adm_ban_name' => 16,
|
||||||
|
];
|
||||||
|
var $log_type_select = [];
|
||||||
var $log_disabled = false;
|
var $log_disabled = false;
|
||||||
|
|
||||||
function init ()
|
function init ()
|
||||||
|
|
|
@ -2,74 +2,32 @@
|
||||||
|
|
||||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||||
|
|
||||||
function get_torrent_info ($attach_id)
|
|
||||||
{
|
|
||||||
global $lang;
|
|
||||||
|
|
||||||
$attach_id = intval($attach_id);
|
|
||||||
|
|
||||||
$sql = "
|
|
||||||
SELECT
|
|
||||||
a.post_id, d.physical_filename, d.extension, d.tracker_status,
|
|
||||||
t.topic_first_post_id,
|
|
||||||
p.poster_id, p.topic_id, p.forum_id,
|
|
||||||
f.allow_reg_tracker
|
|
||||||
FROM
|
|
||||||
". BB_ATTACHMENTS ." a,
|
|
||||||
". BB_ATTACHMENTS_DESC ." d,
|
|
||||||
". BB_POSTS ." p,
|
|
||||||
". BB_TOPICS ." t,
|
|
||||||
". BB_FORUMS ." f
|
|
||||||
WHERE
|
|
||||||
a.attach_id = $attach_id
|
|
||||||
AND d.attach_id = $attach_id
|
|
||||||
AND p.post_id = a.post_id
|
|
||||||
AND t.topic_id = p.topic_id
|
|
||||||
AND f.forum_id = p.forum_id
|
|
||||||
LIMIT 1
|
|
||||||
";
|
|
||||||
|
|
||||||
if (!$torrent = DB()->fetch_row($sql))
|
|
||||||
{
|
|
||||||
bb_die($lang['INVALID_ATTACH_ID']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $torrent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function torrent_auth_check ($forum_id, $poster_id)
|
function torrent_auth_check ($forum_id, $poster_id)
|
||||||
{
|
{
|
||||||
global $userdata, $lang, $attach_config;
|
global $lang, $userdata;
|
||||||
|
|
||||||
if (IS_ADMIN) return true;
|
if (IS_ADMIN || IS_CP_HOLDER || $poster_id == $userdata['user_id'])
|
||||||
|
|
||||||
$is_auth = auth(AUTH_ALL, $forum_id, $userdata);
|
|
||||||
|
|
||||||
if ($poster_id != $userdata['user_id'] && !$is_auth['auth_mod'])
|
|
||||||
{
|
{
|
||||||
bb_die($lang['NOT_MODERATOR']);
|
return true;
|
||||||
}
|
}
|
||||||
else if (!$is_auth['auth_view'] || !$is_auth['auth_attachments'] || $attach_config['disable_mod'])
|
|
||||||
|
if (IS_MOD)
|
||||||
{
|
{
|
||||||
bb_die(sprintf($lang['SORRY_AUTH_READ'], $is_auth['auth_read_type']));
|
$is_auth = auth(AUTH_MOD, $forum_id, $userdata);
|
||||||
|
if ($is_auth['auth_mod']) return true;
|
||||||
}
|
}
|
||||||
return $is_auth;
|
|
||||||
|
bb_die($lang['NOT_MODERATOR']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tracker_unregister ($attach_id, $mode = '')
|
function tracker_unregister ($topic_id, $redirect_url = '')
|
||||||
{
|
{
|
||||||
global $lang, $bb_cfg;
|
global $bb_cfg, $lang, $log_action;
|
||||||
|
|
||||||
$attach_id = (int) $attach_id;
|
$tor = DB()->fetch_row("
|
||||||
$post_id = $topic_id = $forum_id = $info_hash = null;
|
SELECT forum_id, tor_status FROM ". BB_BT_TORRENTS ." WHERE topic_id = ". intval($topic_id) ." LIMIT 1
|
||||||
|
");
|
||||||
// Get torrent info
|
$tor_status = isset($tor['tor_status']) ? $tor['tor_status'] : null;
|
||||||
if ($torrent = get_torrent_info($attach_id))
|
|
||||||
{
|
|
||||||
$post_id = $torrent['post_id'];
|
|
||||||
$topic_id = $torrent['topic_id'];
|
|
||||||
$forum_id = $torrent['forum_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($mode == 'request')
|
if ($mode == 'request')
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,13 +120,14 @@ class upload_common
|
||||||
{
|
{
|
||||||
if ($mode == 'avatar')
|
if ($mode == 'avatar')
|
||||||
{
|
{
|
||||||
delete_avatar($params['user_id'], $params['avatar_ext_id']);
|
delete_avatar($params['user_id'], $this->file_ext_id);
|
||||||
$file_path = get_avatar_path($params['user_id'], $this->file_ext_id);
|
$file_path = get_avatar_path($params['user_id'], $this->file_ext_id);
|
||||||
return $this->_move($file_path);
|
return $this->_move($file_path);
|
||||||
}
|
}
|
||||||
else if ($mode == 'attach')
|
else if ($mode == 'attach')
|
||||||
{
|
{
|
||||||
$file_path = get_attach_path($params['topic_id'], $params['attach_ext_id']);
|
delete_attach($params['topic_id'], $this->file_ext_id);
|
||||||
|
$file_path = get_attach_path($params['topic_id'], $this->file_ext_id);
|
||||||
return $this->_move($file_path);
|
return $this->_move($file_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||||
if (PHP_VERSION < '5.4') die('TorrentPier requires PHP version 5.4 and above. Your PHP version '. PHP_VERSION);
|
|
||||||
if (!defined('BB_SCRIPT')) define('BB_SCRIPT', 'undefined');
|
if (!defined('BB_SCRIPT')) define('BB_SCRIPT', 'undefined');
|
||||||
if (!defined('BB_CFG_LOADED')) trigger_error('File config.php not loaded', E_USER_ERROR);
|
if (!defined('BB_CFG_LOADED')) trigger_error('File config.php not loaded', E_USER_ERROR);
|
||||||
|
|
||||||
|
if (PHP_VERSION < '5.5') die('TorrentPier requires PHP version 5.5 and above (ZF requirement). Your PHP version is '. PHP_VERSION);
|
||||||
|
|
||||||
// Define some basic configuration arrays
|
// Define some basic configuration arrays
|
||||||
unset($stopwords, $synonyms_match, $synonyms_replace);
|
unset($stopwords, $synonyms_match, $synonyms_replace);
|
||||||
$userdata = $theme = $images = $lang = $nav_links = $bf = $attach_config = array();
|
$userdata = $theme = $images = $lang = $nav_links = $bf = [];
|
||||||
$gen_simple_header = false;
|
$gen_simple_header = false;
|
||||||
$user = null;
|
$user = null;
|
||||||
|
|
||||||
|
@ -320,20 +321,21 @@ define('REQUEST', 4);
|
||||||
define('CHBOX', 5);
|
define('CHBOX', 5);
|
||||||
define('SELECT', 6);
|
define('SELECT', 6);
|
||||||
|
|
||||||
if (!empty($banned_user_agents))
|
$dl_link_css = [
|
||||||
{
|
DL_STATUS_RELEASER => 'genmed',
|
||||||
foreach ($banned_user_agents as $agent)
|
DL_STATUS_WILL => 'dlWill',
|
||||||
{
|
DL_STATUS_DOWN => 'leechmed',
|
||||||
if (strstr(USER_AGENT, $agent))
|
DL_STATUS_COMPLETE => 'seedmed',
|
||||||
{
|
DL_STATUS_CANCEL => 'dlCancel',
|
||||||
$filename = 'Download files by using browser';
|
];
|
||||||
$output = '@';
|
|
||||||
header('Content-Type: text/plain');
|
$dl_status_css = [
|
||||||
header('Content-Disposition: attachment; filename="'. $filename .'"');
|
DL_STATUS_RELEASER => 'genmed',
|
||||||
die($output);
|
DL_STATUS_WILL => 'dlWill',
|
||||||
}
|
DL_STATUS_DOWN => 'dlDown',
|
||||||
}
|
DL_STATUS_COMPLETE => 'dlComplete',
|
||||||
}
|
DL_STATUS_CANCEL => 'dlCancel',
|
||||||
|
];
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
function send_no_cache_headers ()
|
function send_no_cache_headers ()
|
||||||
|
@ -449,22 +451,6 @@ if ((empty($_POST) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !file_exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dl_link_css = array(
|
|
||||||
DL_STATUS_RELEASER => 'genmed',
|
|
||||||
DL_STATUS_WILL => 'dlWill',
|
|
||||||
DL_STATUS_DOWN => 'leechmed',
|
|
||||||
DL_STATUS_COMPLETE => 'seedmed',
|
|
||||||
DL_STATUS_CANCEL => 'dlCancel',
|
|
||||||
);
|
|
||||||
|
|
||||||
$dl_status_css = array(
|
|
||||||
DL_STATUS_RELEASER => 'genmed',
|
|
||||||
DL_STATUS_WILL => 'dlWill',
|
|
||||||
DL_STATUS_DOWN => 'dlDown',
|
|
||||||
DL_STATUS_COMPLETE => 'dlComplete',
|
|
||||||
DL_STATUS_CANCEL => 'dlCancel',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Exit if board is disabled via ON/OFF trigger or by admin
|
// Exit if board is disabled via ON/OFF trigger or by admin
|
||||||
if (($bb_cfg['board_disable'] || file_exists(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN'))
|
if (($bb_cfg['board_disable'] || file_exists(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,283 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
function get_attachments_from_post($post_id_array)
|
|
||||||
{
|
|
||||||
global $attach_config;
|
|
||||||
|
|
||||||
$attachments = array();
|
|
||||||
|
|
||||||
if (!is_array($post_id_array))
|
|
||||||
{
|
|
||||||
if (empty($post_id_array))
|
|
||||||
{
|
|
||||||
return $attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_id = intval($post_id_array);
|
|
||||||
|
|
||||||
$post_id_array = array();
|
|
||||||
$post_id_array[] = $post_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_id_array = implode(', ', array_map('intval', $post_id_array));
|
|
||||||
|
|
||||||
if ($post_id_array == '')
|
|
||||||
{
|
|
||||||
return $attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
$display_order = (intval($attach_config['display_order']) == 0) ? 'DESC' : 'ASC';
|
|
||||||
|
|
||||||
$sql = 'SELECT a.post_id, d.*
|
|
||||||
FROM ' . BB_ATTACHMENTS . ' a, ' . BB_ATTACHMENTS_DESC . " d
|
|
||||||
WHERE a.post_id IN ($post_id_array)
|
|
||||||
AND a.attach_id = d.attach_id
|
|
||||||
ORDER BY d.filetime $display_order";
|
|
||||||
|
|
||||||
if (!($result = DB()->sql_query($sql)))
|
|
||||||
{
|
|
||||||
bb_die('Could not get attachment informations for post number ' . $post_id_array);
|
|
||||||
}
|
|
||||||
|
|
||||||
$num_rows = DB()->num_rows($result);
|
|
||||||
$attachments = DB()->sql_fetchrowset($result);
|
|
||||||
DB()->sql_freeresult($result);
|
|
||||||
|
|
||||||
if ($num_rows == 0)
|
|
||||||
{
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get attachment mod configuration
|
|
||||||
*/
|
|
||||||
function get_config()
|
|
||||||
{
|
|
||||||
global $bb_cfg;
|
|
||||||
|
|
||||||
$attach_config = array();
|
|
||||||
|
|
||||||
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
|
|
||||||
|
|
||||||
if (!($result = DB()->sql_query($sql)))
|
|
||||||
{
|
|
||||||
bb_die('Could not query attachment information');
|
|
||||||
}
|
|
||||||
|
|
||||||
while ($row = DB()->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$attach_config[$row['config_name']] = trim($row['config_value']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We assign the original default board language here, because it gets overwritten later with the users default language
|
|
||||||
$attach_config['board_lang'] = trim($bb_cfg['default_lang']);
|
|
||||||
|
|
||||||
return $attach_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get Attachment Config
|
|
||||||
$attach_config = array();
|
|
||||||
|
|
||||||
if (!$attach_config = CACHE('bb_cache')->get('attach_config'))
|
|
||||||
{
|
|
||||||
$attach_config = get_config();
|
|
||||||
CACHE('bb_cache')->set('attach_config', $attach_config, 86400);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writing Data into plain Template Vars
|
|
||||||
*
|
|
||||||
* @param $template_var
|
|
||||||
* @param $replacement
|
|
||||||
* @param string $filename
|
|
||||||
*/
|
|
||||||
function init_display_template($template_var, $replacement, $filename = 'viewtopic_attach.tpl')
|
|
||||||
{
|
|
||||||
global $template;
|
|
||||||
|
|
||||||
// This function is adapted from the old template class
|
|
||||||
// I wish i had the functions from the 3.x one. :D (This class rocks, can't await to use it in Mods)
|
|
||||||
|
|
||||||
// Handle Attachment Informations
|
|
||||||
if (!isset($template->uncompiled_code[$template_var]) && empty($template->uncompiled_code[$template_var]))
|
|
||||||
{
|
|
||||||
// If we don't have a file assigned to this handle, die.
|
|
||||||
if (!isset($template->files[$template_var]))
|
|
||||||
{
|
|
||||||
die("Template->loadfile(): No file specified for handle $template_var");
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename_2 = $template->files[$template_var];
|
|
||||||
|
|
||||||
$str = implode('', @file($filename_2));
|
|
||||||
if (empty($str))
|
|
||||||
{
|
|
||||||
die("Template->loadfile(): File $filename_2 for handle $template_var is empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
$template->uncompiled_code[$template_var] = $str;
|
|
||||||
}
|
|
||||||
|
|
||||||
$complete_filename = $filename;
|
|
||||||
if (substr($complete_filename, 0, 1) != '/')
|
|
||||||
{
|
|
||||||
$complete_filename = $template->root . '/' . $complete_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_exists($complete_filename))
|
|
||||||
{
|
|
||||||
die("Template->make_filename(): Error - file $complete_filename does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = implode('', file($complete_filename));
|
|
||||||
if (empty($content))
|
|
||||||
{
|
|
||||||
die('Template->loadfile(): File ' . $complete_filename . ' is empty');
|
|
||||||
}
|
|
||||||
|
|
||||||
// replace $replacement with uncompiled code in $filename
|
|
||||||
$template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display Attachments in Posts
|
|
||||||
*
|
|
||||||
* @param $post_id
|
|
||||||
* @param $switch_attachment
|
|
||||||
*/
|
|
||||||
function display_post_attachments($post_id, $switch_attachment)
|
|
||||||
{
|
|
||||||
global $attach_config, $is_auth;
|
|
||||||
|
|
||||||
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($is_auth['auth_download'] && $is_auth['auth_view'])
|
|
||||||
{
|
|
||||||
display_attachments($post_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes some templating variables for displaying Attachments in Posts
|
|
||||||
*
|
|
||||||
* @param $switch_attachment
|
|
||||||
*/
|
|
||||||
function init_display_post_attachments($switch_attachment)
|
|
||||||
{
|
|
||||||
global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data;
|
|
||||||
|
|
||||||
if (empty($t_data) && !empty($forum_row))
|
|
||||||
{
|
|
||||||
$switch_attachment = $forum_row['topic_attachment'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view'])))
|
|
||||||
{
|
|
||||||
init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_id_array = array();
|
|
||||||
|
|
||||||
for ($i = 0; $i < $total_posts; $i++)
|
|
||||||
{
|
|
||||||
if ($postrow[$i]['post_attachment'] == 1)
|
|
||||||
{
|
|
||||||
$post_id_array[] = (int) $postrow[$i]['post_id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sizeof($post_id_array) == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = get_attachments_from_post($post_id_array);
|
|
||||||
$num_rows = sizeof($rows);
|
|
||||||
|
|
||||||
if ($num_rows == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@reset($attachments);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $num_rows; $i++)
|
|
||||||
{
|
|
||||||
$attachments['_' . $rows[$i]['post_id']][] = $rows[$i];
|
|
||||||
//bt
|
|
||||||
if ($rows[$i]['tracker_status'])
|
|
||||||
{
|
|
||||||
if (defined('TORRENT_POST'))
|
|
||||||
{
|
|
||||||
bb_die('Multiple registered torrents in one topic<br /><br />first torrent found in post_id = '. TORRENT_POST .'<br />current post_id = '. $rows[$i]['post_id'] .'<br /><br />attachments info:<br /><pre style="text-align: left;">'. print_r($rows, TRUE) .'</pre>');
|
|
||||||
}
|
|
||||||
define('TORRENT_POST', $rows[$i]['post_id']);
|
|
||||||
}
|
|
||||||
//bt end
|
|
||||||
}
|
|
||||||
|
|
||||||
init_display_template('body', '{postrow.ATTACHMENTS}');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function display_attachments($post_id)
|
|
||||||
{
|
|
||||||
global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config;
|
|
||||||
|
|
||||||
$num_attachments = @sizeof($attachments['_' . $post_id]);
|
|
||||||
|
|
||||||
if ($num_attachments == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$template->assign_block_vars('postrow.attach', array());
|
|
||||||
|
|
||||||
for ($i = 0; $i < $num_attachments; $i++)
|
|
||||||
{
|
|
||||||
$upload_image = '';
|
|
||||||
|
|
||||||
if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']]))
|
|
||||||
{
|
|
||||||
$upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
|
|
||||||
}
|
|
||||||
else if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '')
|
|
||||||
{
|
|
||||||
$upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />';
|
|
||||||
}
|
|
||||||
|
|
||||||
$filesize = humn_size($attachments['_' . $post_id][$i]['filesize']);
|
|
||||||
|
|
||||||
$display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']);
|
|
||||||
$comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']);
|
|
||||||
$comment = str_replace("\n", '<br />', $comment);
|
|
||||||
|
|
||||||
$denied = false;
|
|
||||||
|
|
||||||
if (!$denied || IS_ADMIN)
|
|
||||||
{
|
|
||||||
$target_blank = ( (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT) ) ? 'target="_blank"' : '';
|
|
||||||
|
|
||||||
// display attachment
|
|
||||||
$template->assign_block_vars('postrow.attach.attachrow', array(
|
|
||||||
'U_DOWNLOAD_LINK' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'],
|
|
||||||
'S_UPLOAD_IMAGE' => $upload_image,
|
|
||||||
'DOWNLOAD_NAME' => $display_name,
|
|
||||||
'FILESIZE' => $filesize,
|
|
||||||
'COMMENT' => $comment,
|
|
||||||
'TARGET_BLANK' => $target_blank,
|
|
||||||
'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count']),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$upload_dir = $attach_config['upload_dir'];
|
|
|
@ -192,6 +192,7 @@ class user_common
|
||||||
define('IS_GUEST', (!$this->data['session_logged_in']));
|
define('IS_GUEST', (!$this->data['session_logged_in']));
|
||||||
define('IS_ADMIN', (!IS_GUEST && $this->data['user_level'] == ADMIN));
|
define('IS_ADMIN', (!IS_GUEST && $this->data['user_level'] == ADMIN));
|
||||||
define('IS_MOD', (!IS_GUEST && $this->data['user_level'] == MOD));
|
define('IS_MOD', (!IS_GUEST && $this->data['user_level'] == MOD));
|
||||||
|
define('IS_CP_HOLDER', (!IS_GUEST && $this->data['user_level'] == CP_HOLDER));
|
||||||
define('IS_GROUP_MEMBER', (!IS_GUEST && $this->data['user_level'] == GROUP_MEMBER));
|
define('IS_GROUP_MEMBER', (!IS_GUEST && $this->data['user_level'] == GROUP_MEMBER));
|
||||||
define('IS_USER', (!IS_GUEST && $this->data['user_level'] == USER));
|
define('IS_USER', (!IS_GUEST && $this->data['user_level'] == USER));
|
||||||
define('IS_SUPER_ADMIN', (IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']])));
|
define('IS_SUPER_ADMIN', (IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']])));
|
||||||
|
|
|
@ -2,142 +2,56 @@
|
||||||
|
|
||||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||||
|
|
||||||
global $bb_cfg, $t_data, $poster_id, $is_auth, $dl_link_css, $dl_status_css, $lang, $images;
|
global $bb_cfg, $t_data, $poster_id, $is_auth, $dl_link_css, $dl_status_css, $lang, $userdata;
|
||||||
|
|
||||||
$change_peers_bgr_over = true;
|
|
||||||
$bgr_class_1 = 'row1';
|
|
||||||
$bgr_class_2 = 'row2';
|
|
||||||
$bgr_class_over = 'row3';
|
|
||||||
|
|
||||||
$show_peers_limit = 300;
|
$show_peers_limit = 300;
|
||||||
$max_peers_before_overflow = 20;
|
$max_peers_before_overflow = 20;
|
||||||
$peers_overflow_div_height = '400px';
|
|
||||||
$peers_div_style_normal = 'padding: 3px;';
|
$peers_div_style_normal = 'padding: 3px;';
|
||||||
$peers_div_style_overflow = "padding: 6px; height: $peers_overflow_div_height; overflow: auto; border: 1px inset;";
|
$peers_div_style_overflow = "padding: 6px; height: 400px; overflow: auto; border: 1px inset;";
|
||||||
$s_last_seed_date_format = 'Y-m-d';
|
|
||||||
$upload_image = '<img src="'. $images['icon_dn'] .'" alt="'. $lang['DL_TORRENT'] .'" border="0" />';
|
|
||||||
|
|
||||||
$peers_cnt = $seed_count = 0;
|
$peers_cnt = $seed_count = $leech_count = 0;
|
||||||
$seeders = $leechers = '';
|
$seeders = $leechers = '';
|
||||||
$tor_info = array();
|
$tor_info = [];
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars([
|
||||||
'SEED_COUNT' => false,
|
'DL_BUTTONS' => true,
|
||||||
'LEECH_COUNT' => false,
|
'LEECH_COUNT' => false,
|
||||||
'TOR_SPEED_UP' => false,
|
'SEED_COUNT' => false,
|
||||||
'TOR_SPEED_DOWN' => false,
|
'SHOW_CPHOLD_OPT' => (IS_ADMIN || IS_CP_HOLDER),
|
||||||
'SHOW_RATIO_WARN' => false,
|
'SHOW_RATIO_WARN' => false,
|
||||||
));
|
'TOR_CONTROLS' => false,
|
||||||
|
'TOR_SPEED_DOWN' => false,
|
||||||
|
'TOR_SPEED_UP' => false,
|
||||||
|
]);
|
||||||
|
$page_cfg['show_tor_status_select'] = ($is_auth['auth_mod'] || IS_CP_HOLDER);
|
||||||
|
|
||||||
// Define show peers mode (count only || user names with complete % || full details)
|
// Define show peers mode (count only || full details)
|
||||||
$cfg_sp_mode = $bb_cfg['bt_show_peers_mode'];
|
$s_mode = (isset($_GET['spmode']) && $_GET['spmode'] == 'full') ? 'full' : 'count';
|
||||||
$get_sp_mode = (isset($_GET['spmode'])) ? $_GET['spmode'] : '';
|
|
||||||
|
|
||||||
$s_mode = 'count';
|
$tor_file_size = humn_size($t_data['filesize']);
|
||||||
|
$tor_reged = (bool) $t_data['tracker_status'];
|
||||||
if ($cfg_sp_mode == SHOW_PEERS_NAMES)
|
|
||||||
{
|
|
||||||
$s_mode = 'names';
|
|
||||||
}
|
|
||||||
else if ($cfg_sp_mode == SHOW_PEERS_FULL)
|
|
||||||
{
|
|
||||||
$s_mode = 'full';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bb_cfg['bt_allow_spmode_change'])
|
|
||||||
{
|
|
||||||
if ($get_sp_mode == 'names')
|
|
||||||
{
|
|
||||||
$s_mode = 'names';
|
|
||||||
}
|
|
||||||
else if ($get_sp_mode == 'full')
|
|
||||||
{
|
|
||||||
$s_mode = 'full';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$bt_topic_id = $t_data['topic_id'];
|
|
||||||
$bt_user_id = $userdata['user_id'];
|
|
||||||
$attach_id = $attachments['_'. $post_id][$i]['attach_id'];
|
|
||||||
$tracker_status = $attachments['_'. $post_id][$i]['tracker_status'];
|
|
||||||
$download_count = $attachments['_'. $post_id][$i]['download_count'];
|
|
||||||
$tor_file_size = humn_size($attachments['_'. $post_id][$i]['filesize']);
|
|
||||||
$tor_file_time = bb_date($attachments['_'. $post_id][$i]['filetime']);
|
|
||||||
|
|
||||||
$tor_reged = (bool) $tracker_status;
|
|
||||||
$show_peers = (bool) $bb_cfg['bt_show_peers'];
|
|
||||||
|
|
||||||
$locked = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED);
|
$locked = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED);
|
||||||
$tor_auth = ($bt_user_id != GUEST_UID && (($bt_user_id == $poster_id && !$locked) || $is_auth['auth_mod']));
|
$tor_auth = ($bt_user_id != GUEST_UID && (($bt_user_id == $poster_id && !$locked) || $is_auth['auth_mod']));
|
||||||
|
|
||||||
$tor_auth_reg = ($tor_auth && $t_data['allow_reg_tracker'] && $post_id == $t_data['topic_first_post_id']);
|
if ($tor_auth && $t_data['allow_reg_tracker'] && !$tor_reged && !IS_CP_HOLDER /* && $post_id == $t_data['topic_first_post_id']*/)
|
||||||
$tor_auth_del = ($tor_auth && $tor_reged);
|
|
||||||
|
|
||||||
$tracker_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO'];
|
|
||||||
|
|
||||||
$download_link = DOWNLOAD_URL . $attach_id;
|
|
||||||
$description = ($comment) ? $comment : preg_replace("#.torrent$#i", '', $display_name);
|
|
||||||
|
|
||||||
if ($tor_auth_reg || $tor_auth_del)
|
|
||||||
{
|
{
|
||||||
$reg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : '. $attach_id .', type: \'reg\'}); return false;">'. $lang['BT_REG_ON_TRACKER'] .'</a>';
|
$tr_reg_link = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', t : '. $topic_id .', type: \'reg\'}); return false;">'. $lang['BT_REG_ON_TRACKER'] .'</a>';
|
||||||
$unreg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : '. $attach_id .', type: \'unreg\'}); return false;">'. $lang['BT_UNREG_FROM_TRACKER'] .'</a>';
|
|
||||||
|
|
||||||
$tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url;
|
|
||||||
}
|
}
|
||||||
|
else if ($is_auth['auth_mod'] && $tor_reged && !IS_CP_HOLDER)
|
||||||
if ($bb_cfg['torrent_name_style'])
|
|
||||||
{
|
{
|
||||||
$display_name = '['.$bb_cfg['server_name'].'].t' . $bt_topic_id . '.torrent';
|
$tr_reg_link = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', t : '. $topic_id .', type: \'unreg\'}); return false;">'. $lang['BT_UNREG_FROM_TRACKER'] .'</a>';
|
||||||
}
|
|
||||||
|
|
||||||
if (!$tor_reged)
|
|
||||||
{
|
|
||||||
$template->assign_block_vars('postrow.attach.tor_not_reged', array(
|
|
||||||
'DOWNLOAD_NAME' => $display_name,
|
|
||||||
'TRACKER_LINK' => $tracker_link,
|
|
||||||
'ATTACH_ID' => $attach_id,
|
|
||||||
|
|
||||||
'S_UPLOAD_IMAGE' => $upload_image,
|
|
||||||
'U_DOWNLOAD_LINK' => $download_link,
|
|
||||||
'FILESIZE' => $tor_file_size,
|
|
||||||
|
|
||||||
'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count),
|
|
||||||
'POSTED_TIME' => $tor_file_time,
|
|
||||||
));
|
|
||||||
|
|
||||||
if ($comment)
|
|
||||||
{
|
|
||||||
$template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = "SELECT bt.*, u.user_id, u.username, u.user_rank
|
$tr_reg_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO'];
|
||||||
FROM ". BB_BT_TORRENTS ." bt
|
|
||||||
LEFT JOIN ". BB_USERS ." u ON(bt.checked_user_id = u.user_id)
|
|
||||||
WHERE bt.attach_id = $attach_id";
|
|
||||||
|
|
||||||
if (!$result = DB()->sql_query($sql))
|
|
||||||
{
|
|
||||||
bb_die('Could not obtain torrent information');
|
|
||||||
}
|
|
||||||
$tor_info = DB()->sql_fetchrow($result);
|
|
||||||
DB()->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tor_reged && !$tor_info)
|
|
||||||
{
|
|
||||||
DB()->query("UPDATE ". BB_ATTACHMENTS_DESC ." SET tracker_status = 0 WHERE attach_id = $attach_id");
|
|
||||||
|
|
||||||
bb_die('Torrent status fixed');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tor_auth)
|
if ($tor_auth)
|
||||||
{
|
{
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'TOR_CONTROLS' => true,
|
'TOR_CONTROLS' => ($is_auth['auth_mod'] || IS_CP_HOLDER),
|
||||||
'TOR_ATTACH_ID' => $attach_id,
|
'TOR_ACTION' => 'torrent.php',
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($t_data['self_moderated'] || $is_auth['auth_mod'])
|
if ($t_data['self_moderated'] || $is_auth['auth_mod'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue