Реформат в PSR-2 + добавление заголовков лицензии MIT в файлы

This commit is contained in:
Yuriy Pikhtarev 2017-01-13 01:20:43 +03:00
commit 3730bed000
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
207 changed files with 44327 additions and 43119 deletions

10
.styleci.yml Normal file
View file

@ -0,0 +1,10 @@
preset: psr2
finder:
name:
- "*.php"
not-name:
- "*Stub.php"
path:
- "src"
- "tests"

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2005-2017 TorrentPier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,30 +1,48 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['ATTACHMENTS']['CONTROL_PANEL'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['ATTACHMENTS']['CONTROL_PANEL'] = basename(__FILE__);
return;
}
require('./pagestart.php');
$total_attachments = 0;
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':')))
{
$upload_dir = $attach_config['upload_dir'];
}
else
{
$upload_dir = '../' . $attach_config['upload_dir'];
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':'))) {
$upload_dir = $attach_config['upload_dir'];
} else {
$upload_dir = '../' . $attach_config['upload_dir'];
}
include(ATTACH_DIR .'includes/functions_selects.php');
include(ATTACH_DIR . 'includes/functions_selects.php');
// Check if the language got included
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL']))
{
// include_once is used within the function
include_attach_lang();
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL'])) {
// include_once is used within the function
include_attach_lang();
}
// Init Variables
@ -38,40 +56,31 @@ $uid = (isset($_POST['u_id'])) ? get_var('u_id', 0) : get_var('uid', 0);
$view = (isset($_POST['search']) && $_POST['search']) ? 'attachments' : $view;
// process modes based on view
if ($view == 'username')
{
$mode_types_text = array($lang['SORT_USERNAME'], $lang['SORT_ATTACHMENTS'], $lang['SORT_SIZE']);
$mode_types = array('username', 'attachments', 'filesize');
if ($view == 'username') {
$mode_types_text = array($lang['SORT_USERNAME'], $lang['SORT_ATTACHMENTS'], $lang['SORT_SIZE']);
$mode_types = array('username', 'attachments', 'filesize');
if (!$mode)
{
$mode = 'attachments';
$sort_order = 'DESC';
}
}
else if ($view == 'attachments')
{
$mode_types_text = array($lang['SORT_FILENAME'], $lang['SORT_COMMENT'], $lang['SORT_EXTENSION'], $lang['SORT_SIZE'], $lang['SORT_DOWNLOADS'], $lang['SORT_POSTTIME']);
$mode_types = array('real_filename', 'comment', 'extension', 'filesize', 'downloads', 'post_time');
if (!$mode) {
$mode = 'attachments';
$sort_order = 'DESC';
}
} elseif ($view == 'attachments') {
$mode_types_text = array($lang['SORT_FILENAME'], $lang['SORT_COMMENT'], $lang['SORT_EXTENSION'], $lang['SORT_SIZE'], $lang['SORT_DOWNLOADS'], $lang['SORT_POSTTIME']);
$mode_types = array('real_filename', 'comment', 'extension', 'filesize', 'downloads', 'post_time');
if (!$mode)
{
$mode = 'real_filename';
$sort_order = 'ASC';
}
}
else if ($view == 'search')
{
$mode_types_text = array($lang['SORT_FILENAME'], $lang['SORT_COMMENT'], $lang['SORT_EXTENSION'], $lang['SORT_SIZE'], $lang['SORT_DOWNLOADS'], $lang['SORT_POSTTIME']);
$mode_types = array('real_filename', 'comment', 'extension', 'filesize', 'downloads', 'post_time');
if (!$mode) {
$mode = 'real_filename';
$sort_order = 'ASC';
}
} elseif ($view == 'search') {
$mode_types_text = array($lang['SORT_FILENAME'], $lang['SORT_COMMENT'], $lang['SORT_EXTENSION'], $lang['SORT_SIZE'], $lang['SORT_DOWNLOADS'], $lang['SORT_POSTTIME']);
$mode_types = array('real_filename', 'comment', 'extension', 'filesize', 'downloads', 'post_time');
$sort_order = 'DESC';
}
else
{
$view = 'stats';
$mode_types_text = array();
$sort_order = 'ASC';
$sort_order = 'DESC';
} else {
$view = 'stats';
$mode_types_text = array();
$sort_order = 'ASC';
}
// Pagination ?
@ -80,54 +89,49 @@ $do_pagination = ($view != 'stats' && $view != 'search') ? true : false;
// Set Order
$order_by = '';
if ($view == 'username')
{
switch($mode)
{
case 'username':
$order_by = 'ORDER BY u.username ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'attachments':
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'filesize':
$order_by = 'ORDER BY total_size ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
default:
$mode = 'attachments';
$sort_order = 'DESC';
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
}
}
else if ($view == 'attachments')
{
switch($mode)
{
case 'filename':
$order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'comment':
$order_by = 'ORDER BY a.comment ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'extension':
$order_by = 'ORDER BY a.extension ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'filesize':
$order_by = 'ORDER BY a.filesize ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'downloads':
$order_by = 'ORDER BY a.download_count ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'post_time':
$order_by = 'ORDER BY a.filetime ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
default:
$mode = 'a.real_filename';
$sort_order = 'ASC';
$order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
}
if ($view == 'username') {
switch ($mode) {
case 'username':
$order_by = 'ORDER BY u.username ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'attachments':
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'filesize':
$order_by = 'ORDER BY total_size ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
default:
$mode = 'attachments';
$sort_order = 'DESC';
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
}
} elseif ($view == 'attachments') {
switch ($mode) {
case 'filename':
$order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'comment':
$order_by = 'ORDER BY a.comment ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'extension':
$order_by = 'ORDER BY a.extension ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'filesize':
$order_by = 'ORDER BY a.filesize ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'downloads':
$order_by = 'ORDER BY a.download_count ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
case 'post_time':
$order_by = 'ORDER BY a.filetime ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
default:
$mode = 'a.real_filename';
$sort_order = 'ASC';
$order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
}
}
// Set select fields
@ -136,421 +140,368 @@ $view_types = array('stats', 'search');
$select_view = '<select name="view">';
for($i = 0; $i < count($view_types_text); $i++)
{
$selected = ($view == $view_types[$i]) ? ' selected="selected"' : '';
$select_view .= '<option value="' . $view_types[$i] . '"' . $selected . '>' . $view_types_text[$i] . '</option>';
for ($i = 0; $i < count($view_types_text); $i++) {
$selected = ($view == $view_types[$i]) ? ' selected="selected"' : '';
$select_view .= '<option value="' . $view_types[$i] . '"' . $selected . '>' . $view_types_text[$i] . '</option>';
}
$select_view .= '</select>';
if (count($mode_types_text) > 0)
{
$select_sort_mode = '<select name="mode">';
if (count($mode_types_text) > 0) {
$select_sort_mode = '<select name="mode">';
for($i = 0; $i < count($mode_types_text); $i++)
{
$selected = ($mode == $mode_types[$i]) ? ' selected="selected"' : '';
$select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
}
$select_sort_mode .= '</select>';
for ($i = 0; $i < count($mode_types_text); $i++) {
$selected = ($mode == $mode_types[$i]) ? ' selected="selected"' : '';
$select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>';
}
$select_sort_mode .= '</select>';
}
$select_sort_order = '<select name="order">';
if ($sort_order == 'ASC')
{
$select_sort_order .= '<option value="ASC" selected="selected">' . $lang['ASC'] . '</option><option value="DESC">' . $lang['DESC'] . '</option>';
}
else
{
$select_sort_order .= '<option value="ASC">' . $lang['ASC'] . '</option><option value="DESC" selected="selected">' . $lang['DESC'] . '</option>';
if ($sort_order == 'ASC') {
$select_sort_order .= '<option value="ASC" selected="selected">' . $lang['ASC'] . '</option><option value="DESC">' . $lang['DESC'] . '</option>';
} else {
$select_sort_order .= '<option value="ASC">' . $lang['ASC'] . '</option><option value="DESC" selected="selected">' . $lang['DESC'] . '</option>';
}
$select_sort_order .= '</select>';
$submit_change = ( isset($_POST['submit_change']) ) ? TRUE : FALSE;
$delete = ( isset($_POST['delete']) ) ? TRUE : FALSE;
$submit_change = (isset($_POST['submit_change'])) ? true : false;
$delete = (isset($_POST['delete'])) ? true : false;
$delete_id_list = get_var('delete_id_list', array(0));
$confirm = isset($_POST['confirm']);
if ($confirm && sizeof($delete_id_list) > 0)
{
$attachments = array();
if ($confirm && sizeof($delete_id_list) > 0) {
$attachments = array();
delete_attachment(0, $delete_id_list);
}
else if ($delete && sizeof($delete_id_list) > 0)
{
// Not confirmed, show confirmation message
$hidden_fields = '<input type="hidden" name="view" value="' . $view . '" />';
$hidden_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />';
$hidden_fields .= '<input type="hidden" name="order" value="' . $sort_order . '" />';
$hidden_fields .= '<input type="hidden" name="u_id" value="' . $uid . '" />';
$hidden_fields .= '<input type="hidden" name="start" value="' . $start . '" />';
delete_attachment(0, $delete_id_list);
} elseif ($delete && sizeof($delete_id_list) > 0) {
// Not confirmed, show confirmation message
$hidden_fields = '<input type="hidden" name="view" value="' . $view . '" />';
$hidden_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />';
$hidden_fields .= '<input type="hidden" name="order" value="' . $sort_order . '" />';
$hidden_fields .= '<input type="hidden" name="u_id" value="' . $uid . '" />';
$hidden_fields .= '<input type="hidden" name="start" value="' . $start . '" />';
for ($i = 0; $i < sizeof($delete_id_list); $i++)
{
$hidden_fields .= '<input type="hidden" name="delete_id_list[]" value="' . $delete_id_list[$i] . '" />';
}
for ($i = 0; $i < sizeof($delete_id_list); $i++) {
$hidden_fields .= '<input type="hidden" name="delete_id_list[]" value="' . $delete_id_list[$i] . '" />';
}
print_confirmation(array(
'FORM_ACTION' => "admin_attach_cp.php",
'HIDDEN_FIELDS' => $hidden_fields,
));
print_confirmation(array(
'FORM_ACTION' => "admin_attach_cp.php",
'HIDDEN_FIELDS' => $hidden_fields,
));
}
// Assign Default Template Vars
$template->assign_vars(array(
'S_VIEW_SELECT' => $select_view,
'S_MODE_ACTION' => 'admin_attach_cp.php',
'S_VIEW_SELECT' => $select_view,
'S_MODE_ACTION' => 'admin_attach_cp.php',
));
if ($submit_change && $view == 'attachments')
{
$attach_change_list = get_var('attach_id_list', array(0));
$attach_comment_list = get_var('attach_comment_list', array(''));
$attach_download_count_list = get_var('attach_count_list', array(0));
if ($submit_change && $view == 'attachments') {
$attach_change_list = get_var('attach_id_list', array(0));
$attach_comment_list = get_var('attach_comment_list', array(''));
$attach_download_count_list = get_var('attach_count_list', array(0));
// Generate correct Change List
$attachments = array();
// Generate correct Change List
$attachments = array();
for ($i = 0; $i < count($attach_change_list); $i++)
{
$attachments['_' . $attach_change_list[$i]]['comment'] = $attach_comment_list[$i];
$attachments['_' . $attach_change_list[$i]]['download_count'] = $attach_download_count_list[$i];
}
for ($i = 0; $i < count($attach_change_list); $i++) {
$attachments['_' . $attach_change_list[$i]]['comment'] = $attach_comment_list[$i];
$attachments['_' . $attach_change_list[$i]]['download_count'] = $attach_download_count_list[$i];
}
$sql = 'SELECT *
$sql = 'SELECT *
FROM ' . BB_ATTACHMENTS_DESC . '
ORDER BY attach_id';
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not get attachment informations');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get attachment informations');
}
while ( $attachrow = DB()->sql_fetchrow($result) )
{
if ( isset($attachments['_' . $attachrow['attach_id']]) )
{
if ($attachrow['comment'] != $attachments['_' . $attachrow['attach_id']]['comment'] || $attachrow['download_count'] != $attachments['_' . $attachrow['attach_id']]['download_count'])
{
$sql = "UPDATE " . BB_ATTACHMENTS_DESC . "
SET comment = '" . attach_mod_sql_escape($attachments['_' . $attachrow['attach_id']]['comment']) . "', download_count = " . (int) $attachments['_' . $attachrow['attach_id']]['download_count'] . "
WHERE attach_id = " . (int) $attachrow['attach_id'];
while ($attachrow = DB()->sql_fetchrow($result)) {
if (isset($attachments['_' . $attachrow['attach_id']])) {
if ($attachrow['comment'] != $attachments['_' . $attachrow['attach_id']]['comment'] || $attachrow['download_count'] != $attachments['_' . $attachrow['attach_id']]['download_count']) {
$sql = "UPDATE " . BB_ATTACHMENTS_DESC . "
SET comment = '" . attach_mod_sql_escape($attachments['_' . $attachrow['attach_id']]['comment']) . "', download_count = " . (int)$attachments['_' . $attachrow['attach_id']]['download_count'] . "
WHERE attach_id = " . (int)$attachrow['attach_id'];
if (!DB()->sql_query($sql))
{
bb_die('Could not update attachments informations');
}
}
}
}
DB()->sql_freeresult($result);
if (!DB()->sql_query($sql)) {
bb_die('Could not update attachments informations');
}
}
}
}
DB()->sql_freeresult($result);
}
// Statistics
if ($view == 'stats')
{
$upload_dir_size = get_formatted_dirsize();
if ($view == 'stats') {
$upload_dir_size = get_formatted_dirsize();
$attachment_quota = humn_size($attach_config['attachment_quota']);
$attachment_quota = humn_size($attach_config['attachment_quota']);
// number_of_attachments
$row = DB()->fetch_row("
SELECT COUNT(*) AS total FROM ". BB_ATTACHMENTS_DESC ."
// number_of_attachments
$row = DB()->fetch_row("
SELECT COUNT(*) AS total FROM " . BB_ATTACHMENTS_DESC . "
");
$number_of_attachments = $number_of_posts = $row['total'];
$number_of_attachments = $number_of_posts = $row['total'];
$number_of_pms = 0;
$number_of_pms = 0;
// number_of_topics
$row = DB()->fetch_row("
SELECT COUNT(*) AS topics FROM ". BB_TOPICS ." WHERE topic_attachment = 1
// number_of_topics
$row = DB()->fetch_row("
SELECT COUNT(*) AS topics FROM " . BB_TOPICS . " WHERE topic_attachment = 1
");
$number_of_topics = $row['topics'];
$number_of_topics = $row['topics'];
// number_of_users
$row = DB()->fetch_row("
SELECT COUNT(DISTINCT user_id_1) AS users FROM ". BB_ATTACHMENTS ." WHERE post_id != 0
// number_of_users
$row = DB()->fetch_row("
SELECT COUNT(DISTINCT user_id_1) AS users FROM " . BB_ATTACHMENTS . " WHERE post_id != 0
");
$number_of_users = $row['users'];
$template->assign_vars(array(
'TPL_ATTACH_STATISTICS' => true,
'TOTAL_FILESIZE' => $upload_dir_size,
'ATTACH_QUOTA' => $attachment_quota,
'NUMBER_OF_ATTACHMENTS' => $number_of_attachments,
'NUMBER_OF_POSTS' => $number_of_posts,
'NUMBER_OF_PMS' => $number_of_pms,
'NUMBER_OF_TOPICS' => $number_of_topics,
'NUMBER_OF_USERS' => $number_of_users,
));
$number_of_users = $row['users'];
$template->assign_vars(array(
'TPL_ATTACH_STATISTICS' => true,
'TOTAL_FILESIZE' => $upload_dir_size,
'ATTACH_QUOTA' => $attachment_quota,
'NUMBER_OF_ATTACHMENTS' => $number_of_attachments,
'NUMBER_OF_POSTS' => $number_of_posts,
'NUMBER_OF_PMS' => $number_of_pms,
'NUMBER_OF_TOPICS' => $number_of_topics,
'NUMBER_OF_USERS' => $number_of_users,
));
}
// Search
if ($view == 'search')
{
// Get Forums and Categories
//sf - add [, f.forum_parent]
$sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id, f.forum_parent
if ($view == 'search') {
// Get Forums and Categories
//sf - add [, f.forum_parent]
$sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id, f.forum_parent
FROM " . BB_CATEGORIES . " c, " . BB_FORUMS . " f
WHERE f.cat_id = c.cat_id
ORDER BY c.cat_id, f.forum_order";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not obtain forum_name / forum_id');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain forum_name / forum_id');
}
$s_forums = '';
while ($row = DB()->sql_fetchrow($result))
{ //sf
$s_forums .= '<option value="' . $row['forum_id'] . '">' . (($row['forum_parent']) ? HTML_SF_SPACER : '') . htmlCHR($row['forum_name']) . '</option>';
$s_forums = '';
while ($row = DB()->sql_fetchrow($result)) { //sf
$s_forums .= '<option value="' . $row['forum_id'] . '">' . (($row['forum_parent']) ? HTML_SF_SPACER : '') . htmlCHR($row['forum_name']) . '</option>';
if( empty($list_cat[$row['cat_id']]) )
{
$list_cat[$row['cat_id']] = $row['cat_title'];
}
}
if (empty($list_cat[$row['cat_id']])) {
$list_cat[$row['cat_id']] = $row['cat_title'];
}
}
if( $s_forums != '' )
{
$s_forums = '<option value="0">' . $lang['ALL_AVAILABLE'] . '</option>' . $s_forums;
if ($s_forums != '') {
$s_forums = '<option value="0">' . $lang['ALL_AVAILABLE'] . '</option>' . $s_forums;
// Category to search
$s_categories = '<option value="0">' . $lang['ALL_AVAILABLE'] . '</option>';
// Category to search
$s_categories = '<option value="0">' . $lang['ALL_AVAILABLE'] . '</option>';
foreach ($list_cat as $cat_id => $cat_title)
{
$s_categories .= '<option value="' . $cat_id . '">' . htmlCHR($cat_title) . '</option>';
}
}
else
{
bb_die($lang['NO_SEARCHABLE_FORUMS']);
}
foreach ($list_cat as $cat_id => $cat_title) {
$s_categories .= '<option value="' . $cat_id . '">' . htmlCHR($cat_title) . '</option>';
}
} else {
bb_die($lang['NO_SEARCHABLE_FORUMS']);
}
$template->assign_vars(array(
'TPL_ATTACH_SEARCH' => true,
'S_FORUM_OPTIONS' => $s_forums,
'S_CATEGORY_OPTIONS' => $s_categories,
'S_SORT_OPTIONS' => $select_sort_mode,
'S_SORT_ORDER' => $select_sort_order,
));
$template->assign_vars(array(
'TPL_ATTACH_SEARCH' => true,
'S_FORUM_OPTIONS' => $s_forums,
'S_CATEGORY_OPTIONS' => $s_categories,
'S_SORT_OPTIONS' => $select_sort_mode,
'S_SORT_ORDER' => $select_sort_order,
));
}
// Username
if ($view == 'username')
{
$template->assign_vars(array(
'TPL_ATTACH_USER' => true,
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
));
$total_rows = 0;
bb_die('removed');
if ($view == 'username') {
$template->assign_vars(array(
'TPL_ATTACH_USER' => true,
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
));
$total_rows = 0;
bb_die('removed');
}
// Attachments
if ($view == 'attachments')
{
$user_based = ($uid) ? TRUE : FALSE;
$search_based = (isset($_POST['search']) && $_POST['search']) ? TRUE : FALSE;
if ($view == 'attachments') {
$user_based = ($uid) ? true : false;
$search_based = (isset($_POST['search']) && $_POST['search']) ? true : false;
$hidden_fields = '';
$hidden_fields = '';
$template->assign_vars(array(
'TPL_ATTACH_ATTACHMENTS' => true,
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
));
$template->assign_vars(array(
'TPL_ATTACH_ATTACHMENTS' => true,
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
));
$total_rows = 0;
$total_rows = 0;
// Are we called from Username ?
if ($user_based)
{
$sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = " . intval($uid);
// Are we called from Username ?
if ($user_based) {
$sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = " . intval($uid);
if (!($result = DB()->sql_query($sql)))
{
bb_die('Error getting username');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Error getting username');
}
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
$username = $row['username'];
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
$username = $row['username'];
$s_hidden = '<input type="hidden" name="u_id" value="' . intval($uid) . '" />';
$s_hidden = '<input type="hidden" name="u_id" value="' . intval($uid) . '" />';
$template->assign_block_vars('switch_user_based', array());
$template->assign_block_vars('switch_user_based', array());
$template->assign_vars(array(
'S_USER_HIDDEN' => $s_hidden,
'L_STATISTICS_FOR_USER' => sprintf($lang['STATISTICS_FOR_USER'], $username),
));
$template->assign_vars(array(
'S_USER_HIDDEN' => $s_hidden,
'L_STATISTICS_FOR_USER' => sprintf($lang['STATISTICS_FOR_USER'], $username),
));
$sql = "SELECT attach_id
$sql = "SELECT attach_id
FROM " . BB_ATTACHMENTS . "
WHERE user_id_1 = " . intval($uid) . "
GROUP BY attach_id";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachments #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #1');
}
$attach_ids = DB()->sql_fetchrowset($result);
$num_attach_ids = DB()->num_rows($result);
DB()->sql_freeresult($result);
$attach_ids = DB()->sql_fetchrowset($result);
$num_attach_ids = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_attach_ids == 0)
{
bb_die('For some reason no attachments are assigned to the user ' . $username);
}
if ($num_attach_ids == 0) {
bb_die('For some reason no attachments are assigned to the user ' . $username);
}
$total_rows = $num_attach_ids;
$total_rows = $num_attach_ids;
$attach_id = array();
$attach_id = array();
for ($j = 0; $j < $num_attach_ids; $j++)
{
$attach_id[] = intval($attach_ids[$j]['attach_id']);
}
for ($j = 0; $j < $num_attach_ids; $j++) {
$attach_id[] = intval($attach_ids[$j]['attach_id']);
}
$sql = "SELECT a.*
$sql = "SELECT a.*
FROM " . BB_ATTACHMENTS_DESC . " a
WHERE a.attach_id IN (" . implode(', ', $attach_id) . ") " .
$order_by;
$order_by;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachments #2');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #2');
}
$attachments = DB()->sql_fetchrowset($result);
$num_attach = DB()->num_rows($result);
DB()->sql_freeresult($result);
}
else
{
// we are called from search
$attachments = search_attachments($order_by, $total_rows);
}
$attachments = DB()->sql_fetchrowset($result);
$num_attach = DB()->num_rows($result);
DB()->sql_freeresult($result);
} else {
// we are called from search
$attachments = search_attachments($order_by, $total_rows);
}
if (sizeof($attachments) > 0)
{
for ($i = 0; $i < sizeof($attachments); $i++)
{
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" />';
if (sizeof($attachments) > 0) {
for ($i = 0; $i < sizeof($attachments); $i++) {
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" />';
for ($j = 0; $j < count($delete_id_list); $j++)
{
if ($delete_id_list[$j] == $attachments[$i]['attach_id'])
{
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" checked="checked" />';
break;
}
}
for ($j = 0; $j < count($delete_id_list); $j++) {
if ($delete_id_list[$j] == $attachments[$i]['attach_id']) {
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" checked="checked" />';
break;
}
}
$row_class = !($i % 2) ? 'row1' : 'row2';
$row_class = !($i % 2) ? 'row1' : 'row2';
// Is the Attachment assigned to more than one post ?
// If it's not assigned to any post, it's an private message thingy. ;)
$post_titles = array();
// Is the Attachment assigned to more than one post ?
// If it's not assigned to any post, it's an private message thingy. ;)
$post_titles = array();
$sql = "SELECT *
$sql = "SELECT *
FROM " . BB_ATTACHMENTS . "
WHERE attach_id = " . intval($attachments[$i]['attach_id']);
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachments #3');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #3');
}
$ids = DB()->sql_fetchrowset($result);
$num_ids = DB()->num_rows($result);
DB()->sql_freeresult($result);
$ids = DB()->sql_fetchrowset($result);
$num_ids = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($j = 0; $j < $num_ids; $j++)
{
if ($ids[$j]['post_id'] != 0)
{
$sql = "SELECT t.topic_title
for ($j = 0; $j < $num_ids; $j++) {
if ($ids[$j]['post_id'] != 0) {
$sql = "SELECT t.topic_title
FROM " . BB_TOPICS . " t, " . BB_POSTS . " p
WHERE p.post_id = " . intval($ids[$j]['post_id']) . " AND p.topic_id = t.topic_id
GROUP BY t.topic_id, t.topic_title";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query topic');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query topic');
}
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
$post_title = $row['topic_title'];
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
$post_title = $row['topic_title'];
if (strlen($post_title) > 32)
{
$post_title = str_short($post_title, 30);
}
if (strlen($post_title) > 32) {
$post_title = str_short($post_title, 30);
}
$view_topic = BB_ROOT . 'viewtopic.php?' . POST_POST_URL . '=' . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id'];
$view_topic = BB_ROOT . 'viewtopic.php?' . POST_POST_URL . '=' . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id'];
$post_titles[] = '<a href="' . $view_topic . '" class="gen" target="_blank">' . $post_title . '</a>';
}
else
{
$post_titles[] = $lang['PRIVATE_MESSAGE'];
}
}
$post_titles[] = '<a href="' . $view_topic . '" class="gen" target="_blank">' . $post_title . '</a>';
} else {
$post_titles[] = $lang['PRIVATE_MESSAGE'];
}
}
$post_titles = implode('<br />', $post_titles);
$post_titles = implode('<br />', $post_titles);
$hidden_field = '<input type="hidden" name="attach_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" />';
$hidden_field = '<input type="hidden" name="attach_id_list[]" value="' . intval($attachments[$i]['attach_id']) . '" />';
$template->assign_block_vars('attachrow', array(
'ROW_NUMBER' => $i + ( @$_GET['start'] + 1 ),
'ROW_CLASS' => $row_class,
$template->assign_block_vars('attachrow', array(
'ROW_NUMBER' => $i + (@$_GET['start'] + 1),
'ROW_CLASS' => $row_class,
'FILENAME' => htmlspecialchars($attachments[$i]['real_filename']),
'COMMENT' => htmlspecialchars($attachments[$i]['comment']),
'EXTENSION' => $attachments[$i]['extension'],
'SIZE' => round(($attachments[$i]['filesize'] / 1024), 2),
'DOWNLOAD_COUNT' => $attachments[$i]['download_count'],
'POST_TIME' => bb_date($attachments[$i]['filetime']),
'POST_TITLE' => $post_titles,
'FILENAME' => htmlspecialchars($attachments[$i]['real_filename']),
'COMMENT' => htmlspecialchars($attachments[$i]['comment']),
'EXTENSION' => $attachments[$i]['extension'],
'SIZE' => round(($attachments[$i]['filesize'] / 1024), 2),
'DOWNLOAD_COUNT' => $attachments[$i]['download_count'],
'POST_TIME' => bb_date($attachments[$i]['filetime']),
'POST_TITLE' => $post_titles,
'S_DELETE_BOX' => $delete_box,
'S_HIDDEN' => $hidden_field,
'U_VIEW_ATTACHMENT' => BB_ROOT . DOWNLOAD_URL . $attachments[$i]['attach_id'],
));
'S_DELETE_BOX' => $delete_box,
'S_HIDDEN' => $hidden_field,
'U_VIEW_ATTACHMENT' => BB_ROOT . DOWNLOAD_URL . $attachments[$i]['attach_id'],
));
}
}
}
}
if (!$search_based && !$user_based) {
if ($total_attachments == 0) {
$sql = "SELECT attach_id FROM " . BB_ATTACHMENTS_DESC;
if (!$search_based && !$user_based)
{
if ($total_attachments == 0)
{
$sql = "SELECT attach_id FROM " . BB_ATTACHMENTS_DESC;
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachment description table');
}
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachment description table');
}
$total_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
}
}
$total_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
}
}
}
// Generate Pagination
if ($do_pagination && $total_rows > $bb_cfg['topics_per_page'])
{
generate_pagination('admin_attach_cp.php?view=' . $view . '&amp;mode=' . $mode . '&amp;order=' . $sort_order . '&amp;uid=' . $uid, $total_rows, $bb_cfg['topics_per_page'], $start).'&nbsp;';
if ($do_pagination && $total_rows > $bb_cfg['topics_per_page']) {
generate_pagination('admin_attach_cp.php?view=' . $view . '&amp;mode=' . $mode . '&amp;order=' . $sort_order . '&amp;uid=' . $uid, $total_rows, $bb_cfg['topics_per_page'], $start) . '&nbsp;';
}
print_page('admin_attach_cp.tpl', 'admin');
print_page('admin_attach_cp.tpl', 'admin');

File diff suppressed because it is too large Load diff

View file

@ -1,149 +1,166 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['GENERAL']['CONFIGURATION'] = basename(__FILE__) .'?mode=config';
$module['MODS']['CONFIGURATION'] = basename(__FILE__) .'?mode=config_mods';
return;
if (!empty($setmodules)) {
$module['GENERAL']['CONFIGURATION'] = basename(__FILE__) . '?mode=config';
$module['MODS']['CONFIGURATION'] = basename(__FILE__) . '?mode=config_mods';
return;
}
require('./pagestart.php');
require(INC_DIR .'functions_selects.php');
require(INC_DIR . 'functions_selects.php');
$mode = isset($_GET['mode']) ? $_GET['mode'] : '';
$return_links = array(
'index' => '<br /><br />'. sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'),
'config' => '<br /><br />'. sprintf($lang['CLICK_RETURN_CONFIG'], '<a href="admin_board.php?mode=config">', '</a>'),
'config_mods' => '<br /><br />'. sprintf($lang['CLICK_RETURN_CONFIG_MODS'], '<a href="admin_board.php?mode=config_mods">', '</a>')
'index' => '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'),
'config' => '<br /><br />' . sprintf($lang['CLICK_RETURN_CONFIG'], '<a href="admin_board.php?mode=config">', '</a>'),
'config_mods' => '<br /><br />' . sprintf($lang['CLICK_RETURN_CONFIG_MODS'], '<a href="admin_board.php?mode=config_mods">', '</a>')
);
//
// Pull all config data
//
$sql = "SELECT * FROM " . BB_CONFIG;
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not query config information in admin_board');
}
else
{
while ($row = DB()->sql_fetchrow($result))
{
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query config information in admin_board');
} else {
while ($row = DB()->sql_fetchrow($result)) {
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name];
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name];
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name])
{
if ($config_name == 'seed_bonus_points' || $config_name == 'seed_bonus_release' || $config_name == 'bonus_upload' || $config_name == 'bonus_upload_price') $new[$config_name] = serialize(str_replace(',', '.', $new[$config_name]));
bb_update_config(array($config_name => $new[$config_name]));
}
}
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
if ($config_name == 'seed_bonus_points' || $config_name == 'seed_bonus_release' || $config_name == 'bonus_upload' || $config_name == 'bonus_upload_price') {
$new[$config_name] = serialize(str_replace(',', '.', $new[$config_name]));
}
bb_update_config(array($config_name => $new[$config_name]));
}
}
if (isset($_POST['submit']))
{
bb_die($lang['CONFIG_UPDATED'] . $return_links[$mode] . $return_links['index']);
}
if (isset($_POST['submit'])) {
bb_die($lang['CONFIG_UPDATED'] . $return_links[$mode] . $return_links['index']);
}
}
switch ($mode)
{
case 'config_mods':
$template->assign_vars(array(
'S_CONFIG_ACTION' => 'admin_board.php?mode=config_mods',
'CONFIG_MODS' => true,
switch ($mode) {
case 'config_mods':
$template->assign_vars(array(
'S_CONFIG_ACTION' => 'admin_board.php?mode=config_mods',
'CONFIG_MODS' => true,
'MAGNET_LINKS_ENABLED' => $new['magnet_links_enabled'],
'GENDER' => $new['gender'],
'CALLSEED' => $new['callseed'],
'TOR_STATS' => $new['tor_stats'],
'SHOW_LATEST_NEWS' => $new['show_latest_news'],
'MAX_NEWS_TITLE' => $new['max_news_title'],
'LATEST_NEWS_COUNT' => $new['latest_news_count'],
'LATEST_NEWS_FORUM_ID' => $new['latest_news_forum_id'],
'SHOW_NETWORK_NEWS' => $new['show_network_news'],
'MAX_NET_TITLE' => $new['max_net_title'],
'NETWORK_NEWS_COUNT' => $new['network_news_count'],
'NETWORK_NEWS_FORUM_ID' => $new['network_news_forum_id'],
'WHOIS_INFO' => $new['whois_info'],
'SHOW_MOD_INDEX' => $new['show_mod_index'],
'BIRTHDAY_ENABLED' => $new['birthday_enabled'],
'BIRTHDAY_MAX_AGE' => $new['birthday_max_age'],
'BIRTHDAY_MIN_AGE' => $new['birthday_min_age'],
'BIRTHDAY_CHECK_DAY' => $new['birthday_check_day'],
'PREMOD' => $new['premod'],
'TOR_COMMENT' => $new['tor_comment'],
'NEW_TPLS' => $new['new_tpls'],
'SEED_BONUS_ENABLED' => $new['seed_bonus_enabled'],
'SEED_BONUS_TOR_SIZE' => $new['seed_bonus_tor_size'],
'SEED_BONUS_USER_REGDATE' => $new['seed_bonus_user_regdate'],
));
'MAGNET_LINKS_ENABLED' => $new['magnet_links_enabled'],
'GENDER' => $new['gender'],
'CALLSEED' => $new['callseed'],
'TOR_STATS' => $new['tor_stats'],
'SHOW_LATEST_NEWS' => $new['show_latest_news'],
'MAX_NEWS_TITLE' => $new['max_news_title'],
'LATEST_NEWS_COUNT' => $new['latest_news_count'],
'LATEST_NEWS_FORUM_ID' => $new['latest_news_forum_id'],
'SHOW_NETWORK_NEWS' => $new['show_network_news'],
'MAX_NET_TITLE' => $new['max_net_title'],
'NETWORK_NEWS_COUNT' => $new['network_news_count'],
'NETWORK_NEWS_FORUM_ID' => $new['network_news_forum_id'],
'WHOIS_INFO' => $new['whois_info'],
'SHOW_MOD_INDEX' => $new['show_mod_index'],
'BIRTHDAY_ENABLED' => $new['birthday_enabled'],
'BIRTHDAY_MAX_AGE' => $new['birthday_max_age'],
'BIRTHDAY_MIN_AGE' => $new['birthday_min_age'],
'BIRTHDAY_CHECK_DAY' => $new['birthday_check_day'],
'PREMOD' => $new['premod'],
'TOR_COMMENT' => $new['tor_comment'],
'NEW_TPLS' => $new['new_tpls'],
'SEED_BONUS_ENABLED' => $new['seed_bonus_enabled'],
'SEED_BONUS_TOR_SIZE' => $new['seed_bonus_tor_size'],
'SEED_BONUS_USER_REGDATE' => $new['seed_bonus_user_regdate'],
));
if ($new['seed_bonus_points'] && $new['seed_bonus_release'])
{
$seed_bonus = unserialize($new['seed_bonus_points']);
$seed_release = unserialize($new['seed_bonus_release']);
if ($new['seed_bonus_points'] && $new['seed_bonus_release']) {
$seed_bonus = unserialize($new['seed_bonus_points']);
$seed_release = unserialize($new['seed_bonus_release']);
foreach ($seed_bonus as $i => $row)
{
if (!$row || !$seed_release[$i]) continue;
foreach ($seed_bonus as $i => $row) {
if (!$row || !$seed_release[$i]) {
continue;
}
$template->assign_block_vars('seed_bonus', array(
'RELEASE' => $seed_release[$i],
'POINTS' => $row,
));
}
}
$template->assign_block_vars('seed_bonus', array(
'RELEASE' => $seed_release[$i],
'POINTS' => $row,
));
}
}
if ($new['bonus_upload'] && $new['bonus_upload_price'])
{
$upload_row = unserialize($new['bonus_upload']);
$price_row = unserialize($new['bonus_upload_price']);
if ($new['bonus_upload'] && $new['bonus_upload_price']) {
$upload_row = unserialize($new['bonus_upload']);
$price_row = unserialize($new['bonus_upload_price']);
foreach ($upload_row as $i => $row)
{
if (!$row || !$price_row[$i]) continue;
foreach ($upload_row as $i => $row) {
if (!$row || !$price_row[$i]) {
continue;
}
$template->assign_block_vars('bonus_upload', array(
'UP' => $row,
'PRICE' => $price_row[$i],
));
}
}
break;
$template->assign_block_vars('bonus_upload', array(
'UP' => $row,
'PRICE' => $price_row[$i],
));
}
}
break;
default:
$template->assign_vars(array(
'S_CONFIG_ACTION' => 'admin_board.php?mode=config',
'CONFIG' => true,
default:
$template->assign_vars(array(
'S_CONFIG_ACTION' => 'admin_board.php?mode=config',
'CONFIG' => true,
'SITENAME' => htmlCHR($new['sitename']),
'CONFIG_SITE_DESCRIPTION' => htmlCHR($new['site_desc']),
'DISABLE_BOARD' => ($new['board_disable']) ? true : false,
'ALLOW_AUTOLOGIN' => ($new['allow_autologin']) ? true : false,
'AUTOLOGIN_TIME' => (int) $new['max_autologin_time'],
'MAX_POLL_OPTIONS' => $new['max_poll_options'],
'FLOOD_INTERVAL' => $new['flood_interval'],
'TOPICS_PER_PAGE' => $new['topics_per_page'],
'POSTS_PER_PAGE' => $new['posts_per_page'],
'HOT_TOPIC' => $new['hot_threshold'],
'DEFAULT_DATEFORMAT' => $new['default_dateformat'],
'LANG_SELECT' => language_select($new['default_lang'], 'default_lang'),
'TIMEZONE_SELECT' => tz_select($new['board_timezone'], 'board_timezone'),
'MAX_LOGIN_ATTEMPTS' => $new['max_login_attempts'],
'LOGIN_RESET_TIME' => $new['login_reset_time'],
'PRUNE_ENABLE' => ($new['prune_enable']) ? true : false,
'ALLOW_BBCODE' => ($new['allow_bbcode']) ? true : false,
'ALLOW_SMILIES' => ($new['allow_smilies']) ? true : false,
'ALLOW_SIG' => ($new['allow_sig']) ? true : false,
'SIG_SIZE' => $new['max_sig_chars'],
'ALLOW_NAMECHANGE' => ($new['allow_namechange']) ? true : false,
'SMILIES_PATH' => $new['smilies_path'],
));
break;
'SITENAME' => htmlCHR($new['sitename']),
'CONFIG_SITE_DESCRIPTION' => htmlCHR($new['site_desc']),
'DISABLE_BOARD' => ($new['board_disable']) ? true : false,
'ALLOW_AUTOLOGIN' => ($new['allow_autologin']) ? true : false,
'AUTOLOGIN_TIME' => (int)$new['max_autologin_time'],
'MAX_POLL_OPTIONS' => $new['max_poll_options'],
'FLOOD_INTERVAL' => $new['flood_interval'],
'TOPICS_PER_PAGE' => $new['topics_per_page'],
'POSTS_PER_PAGE' => $new['posts_per_page'],
'HOT_TOPIC' => $new['hot_threshold'],
'DEFAULT_DATEFORMAT' => $new['default_dateformat'],
'LANG_SELECT' => language_select($new['default_lang'], 'default_lang'),
'TIMEZONE_SELECT' => tz_select($new['board_timezone'], 'board_timezone'),
'MAX_LOGIN_ATTEMPTS' => $new['max_login_attempts'],
'LOGIN_RESET_TIME' => $new['login_reset_time'],
'PRUNE_ENABLE' => ($new['prune_enable']) ? true : false,
'ALLOW_BBCODE' => ($new['allow_bbcode']) ? true : false,
'ALLOW_SMILIES' => ($new['allow_smilies']) ? true : false,
'ALLOW_SIG' => ($new['allow_sig']) ? true : false,
'SIG_SIZE' => $new['max_sig_chars'],
'ALLOW_NAMECHANGE' => ($new['allow_namechange']) ? true : false,
'SMILIES_PATH' => $new['smilies_path'],
));
break;
}
print_page('admin_board.tpl', 'admin');
print_page('admin_board.tpl', 'admin');

View file

@ -1,150 +1,165 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['TP']['FORUM_CONFIG'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['TP']['FORUM_CONFIG'] = basename(__FILE__);
return;
}
require('./pagestart.php');
$max_forum_name_len = 30;
$max_forum_rows = 25;
$max_forum_rows = 25;
require(INC_DIR .'functions_admin_torrent.php');
require(INC_DIR . 'functions_admin_torrent.php');
$submit = isset($_POST['submit']);
$submit = isset($_POST['submit']);
$confirm = isset($_POST['confirm']);
$cfg = array();
// All config names with default values
$default_cfg_str = array(
'bt_announce_url' => 'http://demo.torrentpier.me/bt/',
'bt_announce_url' => 'http://demo.torrentpier.me/bt/',
);
$default_cfg_bool = array(
'bt_disable_dht' => 1,
'bt_show_peers' => 1,
'bt_add_auth_key' => 1,
'bt_show_dl_list' => 0,
'bt_dl_list_only_1st_page' => 1,
'bt_dl_list_only_count' => 1,
'bt_replace_ann_url' => 1,
'bt_show_ip_only_moder' => 1,
'bt_show_port_only_moder' => 1,
'bt_check_announce_url' => 0,
'bt_show_dl_list_buttons' => 1,
'bt_show_dl_but_will' => 1,
'bt_show_dl_but_down' => 0,
'bt_show_dl_but_compl' => 1,
'bt_show_dl_but_cancel' => 1,
'bt_show_dl_stat_on_index' => 1,
'bt_newtopic_auto_reg' => 1,
'bt_tor_browse_only_reg' => 1,
'bt_search_bool_mode' => 1,
'bt_allow_spmode_change' => 1,
'bt_del_addit_ann_urls' => 1,
'bt_set_dltype_on_tor_reg' => 1,
'bt_unset_dltype_on_tor_unreg' => 1,
'bt_disable_dht' => 1,
'bt_show_peers' => 1,
'bt_add_auth_key' => 1,
'bt_show_dl_list' => 0,
'bt_dl_list_only_1st_page' => 1,
'bt_dl_list_only_count' => 1,
'bt_replace_ann_url' => 1,
'bt_show_ip_only_moder' => 1,
'bt_show_port_only_moder' => 1,
'bt_check_announce_url' => 0,
'bt_show_dl_list_buttons' => 1,
'bt_show_dl_but_will' => 1,
'bt_show_dl_but_down' => 0,
'bt_show_dl_but_compl' => 1,
'bt_show_dl_but_cancel' => 1,
'bt_show_dl_stat_on_index' => 1,
'bt_newtopic_auto_reg' => 1,
'bt_tor_browse_only_reg' => 1,
'bt_search_bool_mode' => 1,
'bt_allow_spmode_change' => 1,
'bt_del_addit_ann_urls' => 1,
'bt_set_dltype_on_tor_reg' => 1,
'bt_unset_dltype_on_tor_unreg' => 1,
);
$default_cfg_num = array(
'bt_show_peers_mode' => SHOW_PEERS_COUNT,
'bt_show_peers_mode' => SHOW_PEERS_COUNT,
);
$default_cfg = array_merge($default_cfg_str, $default_cfg_bool, $default_cfg_num);
$db_fields_bool = array(
'allow_reg_tracker' => 0, // Allowed forums for registering torrents on tracker
'allow_porno_topic' => 0, // Allowed forums for porno topics
'self_moderated' => 0, // Users can move theirs topic to another forum
'allow_reg_tracker' => 0, // Allowed forums for registering torrents on tracker
'allow_porno_topic' => 0, // Allowed forums for porno topics
'self_moderated' => 0, // Users can move theirs topic to another forum
);
// Get config
$cfg = bb_get_config(BB_CONFIG, true, false);
// Submit new config
if ($submit && $confirm)
{
foreach ($db_fields_bool as $field_name => $field_def_val)
{
update_table_bool(BB_FORUMS, 'forum_id', $field_name, $field_def_val);
}
if ($submit && $confirm) {
foreach ($db_fields_bool as $field_name => $field_def_val) {
update_table_bool(BB_FORUMS, 'forum_id', $field_name, $field_def_val);
}
update_config_table(BB_CONFIG, $default_cfg_str, $cfg, 'str');
update_config_table(BB_CONFIG, $default_cfg_bool, $cfg, 'bool');
update_config_table(BB_CONFIG, $default_cfg_num, $cfg, 'num');
update_config_table(BB_CONFIG, $default_cfg_str, $cfg, 'str');
update_config_table(BB_CONFIG, $default_cfg_bool, $cfg, 'bool');
update_config_table(BB_CONFIG, $default_cfg_num, $cfg, 'num');
$datastore->update('cat_forums');
$datastore->update('cat_forums');
bb_die($lang['CONFIG_UPD'] .'<br /><br />'. sprintf($lang['RETURN_CONFIG'], '<a href="admin_bt_forum_cfg.php">', '</a>') .'<br /><br />'. sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
bb_die($lang['CONFIG_UPD'] . '<br /><br />' . sprintf($lang['RETURN_CONFIG'], '<a href="admin_bt_forum_cfg.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
// Set template vars
set_tpl_vars ($default_cfg_str, $cfg);
set_tpl_vars_lang ($default_cfg_str);
set_tpl_vars($default_cfg_str, $cfg);
set_tpl_vars_lang($default_cfg_str);
set_tpl_vars_bool ($default_cfg_bool, $cfg);
set_tpl_vars_lang ($default_cfg_bool);
set_tpl_vars_bool($default_cfg_bool, $cfg);
set_tpl_vars_lang($default_cfg_bool);
set_tpl_vars ($default_cfg_num, $cfg);
set_tpl_vars_lang ($default_cfg_num);
set_tpl_vars($default_cfg_num, $cfg);
set_tpl_vars_lang($default_cfg_num);
set_tpl_vars_lang ($db_fields_bool);
set_tpl_vars_lang($db_fields_bool);
// Get Forums list
$sql = "SELECT f.*
FROM ". BB_CATEGORIES ." c, ". BB_FORUMS ." f
FROM " . BB_CATEGORIES . " c, " . BB_FORUMS . " f
WHERE f.cat_id = c.cat_id
ORDER BY c.cat_order, f.forum_order";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not obtain forum names');
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain forum names');
}
$rowset = DB()->sql_fetchrowset($result);
$forum_rows = min($max_forum_rows, count($rowset));
foreach ($db_fields_bool as $field_name => $field_def_val)
{
$$field_name = '';
foreach ($db_fields_bool as $field_name => $field_def_val) {
$$field_name = '';
}
foreach ($rowset as $rid => $forum)
{
foreach ($db_fields_bool as $field_name => $field_def_val)
{
$forum_name = $forum['forum_name'];
$selected = ($forum[$field_name]) ? ' selected="selected"' : '';
foreach ($rowset as $rid => $forum) {
foreach ($db_fields_bool as $field_name => $field_def_val) {
$forum_name = $forum['forum_name'];
$selected = ($forum[$field_name]) ? ' selected="selected"' : '';
$forum_name = str_short($forum_name, $max_forum_name_len);
$forum_name = str_short($forum_name, $max_forum_name_len);
$$field_name .= '<option value="'. $forum['forum_id'] .'" '. $selected .'>&nbsp;' . (($forum['forum_parent']) ? HTML_SF_SPACER : '') . htmlCHR($forum_name) ."</option>\n";
}
$$field_name .= '<option value="' . $forum['forum_id'] . '" ' . $selected . '>&nbsp;' . (($forum['forum_parent']) ? HTML_SF_SPACER : '') . htmlCHR($forum_name) . "</option>\n";
}
}
foreach ($db_fields_bool as $field_name => $field_def_val)
{
$$field_name = '<select name="'. $field_name ."[]\" multiple=\"multiple\" size=\"$forum_rows\">". $$field_name .'</select>';
$template->assign_vars(array('S_'. strtoupper($field_name) => $$field_name));
foreach ($db_fields_bool as $field_name => $field_def_val) {
$$field_name = '<select name="' . $field_name . "[]\" multiple=\"multiple\" size=\"$forum_rows\">" . $$field_name . '</select>';
$template->assign_vars(array('S_' . strtoupper($field_name) => $$field_name));
}
$template->assign_vars(array(
'L_BT_SHOW_PEERS_MODE_COUNT' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_COUNT) ? '<u>'. $lang['BT_SHOW_PEERS_MODE_COUNT'] .'</u>' : $lang['BT_SHOW_PEERS_MODE_COUNT'],
'L_BT_SHOW_PEERS_MODE_NAMES' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_NAMES) ? '<u>'. $lang['BT_SHOW_PEERS_MODE_NAMES'] .'</u>' : $lang['BT_SHOW_PEERS_MODE_NAMES'],
'L_BT_SHOW_PEERS_MODE_FULL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_FULL) ? '<u>'. $lang['BT_SHOW_PEERS_MODE_FULL'] .'</u>' : $lang['BT_SHOW_PEERS_MODE_FULL'],
'L_BT_SHOW_PEERS_MODE_COUNT' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_COUNT) ? '<u>' . $lang['BT_SHOW_PEERS_MODE_COUNT'] . '</u>' : $lang['BT_SHOW_PEERS_MODE_COUNT'],
'L_BT_SHOW_PEERS_MODE_NAMES' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_NAMES) ? '<u>' . $lang['BT_SHOW_PEERS_MODE_NAMES'] . '</u>' : $lang['BT_SHOW_PEERS_MODE_NAMES'],
'L_BT_SHOW_PEERS_MODE_FULL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_FULL) ? '<u>' . $lang['BT_SHOW_PEERS_MODE_FULL'] . '</u>' : $lang['BT_SHOW_PEERS_MODE_FULL'],
'BT_SHOW_PEERS_MODE_COUNT_VAL' => SHOW_PEERS_COUNT,
'BT_SHOW_PEERS_MODE_NAMES_VAL' => SHOW_PEERS_NAMES,
'BT_SHOW_PEERS_MODE_FULL_VAL' => SHOW_PEERS_FULL,
'BT_SHOW_PEERS_MODE_COUNT_VAL' => SHOW_PEERS_COUNT,
'BT_SHOW_PEERS_MODE_NAMES_VAL' => SHOW_PEERS_NAMES,
'BT_SHOW_PEERS_MODE_FULL_VAL' => SHOW_PEERS_FULL,
'BT_SHOW_PEERS_MODE_COUNT_SEL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_COUNT) ? HTML_CHECKED : '',
'BT_SHOW_PEERS_MODE_NAMES_SEL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_NAMES) ? HTML_CHECKED : '',
'BT_SHOW_PEERS_MODE_FULL_SEL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_FULL) ? HTML_CHECKED : '',
'BT_SHOW_PEERS_MODE_COUNT_SEL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_COUNT) ? HTML_CHECKED : '',
'BT_SHOW_PEERS_MODE_NAMES_SEL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_NAMES) ? HTML_CHECKED : '',
'BT_SHOW_PEERS_MODE_FULL_SEL' => ($cfg['bt_show_peers_mode'] == SHOW_PEERS_FULL) ? HTML_CHECKED : '',
'S_HIDDEN_FIELDS' => '',
'S_CONFIG_ACTION' => 'admin_bt_forum_cfg.php',
'S_HIDDEN_FIELDS' => '',
'S_CONFIG_ACTION' => 'admin_bt_forum_cfg.php',
));
print_page('admin_bt_forum_cfg.tpl', 'admin');
print_page('admin_bt_forum_cfg.tpl', 'admin');

View file

@ -1,64 +1,90 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
if (IS_SUPER_ADMIN) $module['TP']['TRACKER_CONFIG'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
if (IS_SUPER_ADMIN) {
$module['TP']['TRACKER_CONFIG'] = basename(__FILE__);
}
return;
}
require('./pagestart.php');
if (!IS_SUPER_ADMIN) bb_die($lang['NOT_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['NOT_ADMIN']);
}
require(INC_DIR .'functions_admin_torrent.php');
require(INC_DIR . 'functions_admin_torrent.php');
$submit = isset($_POST['submit']);
$confirmed = isset($_POST['confirm']);
$submit = isset($_POST['submit']);
$confirmed = isset($_POST['confirm']);
// All config names with default values
$default_cfg_str = array(
'off_reason' => 'Tracker is disabled',
'browser_redirect_url' => 'http://demo.torrentpier.me/',
'off_reason' => 'Tracker is disabled',
'browser_redirect_url' => 'http://demo.torrentpier.me/',
);
$default_cfg_bool = array(
'autoclean' => 1,
'off' => 0,
'compact_mode' => 1,
'update_dlstat' => 1,
'limit_active_tor' => 0,
'limit_concurrent_ips' => 0,
'retracker' => 1,
'autoclean' => 1,
'off' => 0,
'compact_mode' => 1,
'update_dlstat' => 1,
'limit_active_tor' => 0,
'limit_concurrent_ips' => 0,
'retracker' => 1,
);
$default_cfg_num = array(
'numwant' => 50,
'expire_factor' => 4,
'limit_seed_count' => 20,
'limit_leech_count' => 4,
'leech_expire_factor' => 60,
'limit_seed_ips' => 0,
'limit_leech_ips' => 0,
'numwant' => 50,
'expire_factor' => 4,
'limit_seed_count' => 20,
'limit_leech_count' => 4,
'leech_expire_factor' => 60,
'limit_seed_ips' => 0,
'limit_leech_ips' => 0,
);
// Set template vars
set_tpl_vars ($default_cfg_str, $tr_cfg);
set_tpl_vars_lang ($default_cfg_str);
set_tpl_vars($default_cfg_str, $tr_cfg);
set_tpl_vars_lang($default_cfg_str);
set_tpl_vars_bool ($default_cfg_bool, $tr_cfg);
set_tpl_vars_lang ($default_cfg_bool);
set_tpl_vars_bool($default_cfg_bool, $tr_cfg);
set_tpl_vars_lang($default_cfg_bool);
set_tpl_vars ($default_cfg_num, $tr_cfg);
set_tpl_vars_lang ($default_cfg_num);
set_tpl_vars($default_cfg_num, $tr_cfg);
set_tpl_vars_lang($default_cfg_num);
$template->assign_vars(array(
'IGNORE_REPORTED_IP' => $bb_cfg['ignore_reported_ip'],
'ANNOUNCE_INTERVAL' => $bb_cfg['announce_interval'],
'PASSKEY_KEY' => $bb_cfg['passkey_key'],
'GOLD_SILVER_ENABLED' => $tr_cfg['gold_silver_enabled'],
'DISABLE_SUBMIT' => true,
'IGNORE_REPORTED_IP' => $bb_cfg['ignore_reported_ip'],
'ANNOUNCE_INTERVAL' => $bb_cfg['announce_interval'],
'PASSKEY_KEY' => $bb_cfg['passkey_key'],
'GOLD_SILVER_ENABLED' => $tr_cfg['gold_silver_enabled'],
'DISABLE_SUBMIT' => true,
'S_HIDDEN_FIELDS' => '',
'S_CONFIG_ACTION' => 'admin_bt_tracker_cfg.php',
'S_HIDDEN_FIELDS' => '',
'S_CONFIG_ACTION' => 'admin_bt_tracker_cfg.php',
));
print_page('admin_bt_tracker_cfg.tpl', 'admin');
print_page('admin_bt_tracker_cfg.tpl', 'admin');

View file

@ -1,228 +1,230 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
if (IS_SUPER_ADMIN) $module['TP']['CRON'] = basename(__FILE__) . '?mode=list';
return;
if (!empty($setmodules)) {
if (IS_SUPER_ADMIN) {
$module['TP']['CRON'] = basename(__FILE__) . '?mode=list';
}
return;
}
$mode = isset($_GET['mode']) ? $_GET['mode'] : '';
$job_id = isset($_GET['id']) ? (int) $_GET['id'] : '';
$submit = isset($_POST['submit']);
$job_id = isset($_GET['id']) ? (int)$_GET['id'] : '';
$submit = isset($_POST['submit']);
$jobs = isset($_POST['select']) ? implode(',', $_POST['select']) : '';
$cron_action = isset($_POST['cron_action']) ? $_POST['cron_action'] : '';
if ($mode == 'run' && !$job_id)
{
define('BB_ROOT', './../');
require(BB_ROOT.'common.php');
$user->session_start();
redirect('admin/'.basename(__FILE__) . '?mode=list');
if ($mode == 'run' && !$job_id) {
define('BB_ROOT', './../');
require(BB_ROOT . 'common.php');
$user->session_start();
redirect('admin/' . basename(__FILE__) . '?mode=list');
} else {
require('./pagestart.php');
}
else require('./pagestart.php');
if (!IS_SUPER_ADMIN) bb_die($lang['NOT_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['NOT_ADMIN']);
}
require(INC_DIR .'functions_admin_torrent.php');
require(INC_DIR .'functions_admin_cron.php');
require(INC_DIR . 'functions_admin_torrent.php');
require(INC_DIR . 'functions_admin_cron.php');
$sql = DB()->fetch_rowset("SELECT * FROM ". BB_CONFIG ." WHERE config_name = 'cron_enabled' OR config_name = 'cron_check_interval'");
$sql = DB()->fetch_rowset("SELECT * FROM " . BB_CONFIG . " WHERE config_name = 'cron_enabled' OR config_name = 'cron_check_interval'");
foreach ($sql as $row)
{
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
foreach ($sql as $row) {
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name];
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name];
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name])
{
bb_update_config(array($config_name => $new[$config_name]));
}
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
bb_update_config(array($config_name => $new[$config_name]));
}
}
$template->assign_vars(array(
'CRON_ENABLED' => ($new['cron_enabled']) ? true : false,
'CRON_CHECK_INTERVAL' => $new['cron_check_interval'],
'CRON_ENABLED' => ($new['cron_enabled']) ? true : false,
'CRON_CHECK_INTERVAL' => $new['cron_check_interval'],
));
switch ($mode)
{
case 'list':
$sql = DB()->fetch_rowset("SELECT * FROM ". BB_CRON ." ORDER BY cron_id");
switch ($mode) {
case 'list':
$sql = DB()->fetch_rowset("SELECT * FROM " . BB_CRON . " ORDER BY cron_id");
foreach ($sql as $i => $row)
{
$template->assign_block_vars('list', array(
'ROW_CLASS' => !($i % 2) ? 'row2' : 'row1',
'JOB_ID' => $i + 1,
'CRON_ID' => $row['cron_id'],
'CRON_ACTIVE' => $row['cron_active'] ? '<img src="../styles/images/icon_run.gif" alt="'. $lang['YES'] .'" />' : '<img src="../styles/images/icon_delete.gif" alt="'. $lang['NO'] .'" />',
'CRON_TITLE' => $row['cron_title'],
'CRON_SCRIPT' => $row['cron_script'],
'SCHEDULE' => $row['schedule'] ? $lang['SCHEDULE'][$row['schedule']] : '<b class="leech">'. $lang['NOSELECT'] .'</b>',
'RUN_DAY' => $row['run_day'],
'LAST_RUN' => $row['last_run'],
'NEXT_RUN' => $row['next_run'],
'RUN_COUNT' => $row['run_counter'],
));
}
foreach ($sql as $i => $row) {
$template->assign_block_vars('list', array(
'ROW_CLASS' => !($i % 2) ? 'row2' : 'row1',
'JOB_ID' => $i + 1,
'CRON_ID' => $row['cron_id'],
'CRON_ACTIVE' => $row['cron_active'] ? '<img src="../styles/images/icon_run.gif" alt="' . $lang['YES'] . '" />' : '<img src="../styles/images/icon_delete.gif" alt="' . $lang['NO'] . '" />',
'CRON_TITLE' => $row['cron_title'],
'CRON_SCRIPT' => $row['cron_script'],
'SCHEDULE' => $row['schedule'] ? $lang['SCHEDULE'][$row['schedule']] : '<b class="leech">' . $lang['NOSELECT'] . '</b>',
'RUN_DAY' => $row['run_day'],
'LAST_RUN' => $row['last_run'],
'NEXT_RUN' => $row['next_run'],
'RUN_COUNT' => $row['run_counter'],
));
}
$template->assign_vars(array(
'TPL_CRON_LIST' => true,
'S_CRON_ACTION' => 'admin_cron.php',
'S_MODE' => 'list',
));
$template->assign_vars(array(
'TPL_CRON_LIST' => true,
'S_CRON_ACTION' => 'admin_cron.php',
'S_MODE' => 'list',
));
//detect cron status
if (@file_exists('../triggers/cron_running'))
{
$template->assign_vars(array(
'CRON_RUNNING' => true,
));
}
break;
//detect cron status
if (@file_exists('../triggers/cron_running')) {
$template->assign_vars(array(
'CRON_RUNNING' => true,
));
}
break;
case 'repair':
if (@file_exists('../triggers/cron_running'))
{
rename("../triggers/cron_running", "../triggers/cron_allowed");
}
redirect('admin/'.basename(__FILE__) . '?mode=list');
break;
case 'repair':
if (@file_exists('../triggers/cron_running')) {
rename("../triggers/cron_running", "../triggers/cron_allowed");
}
redirect('admin/' . basename(__FILE__) . '?mode=list');
break;
case 'run':
run_jobs($job_id);
redirect('admin/'.basename(__FILE__) . '?mode=list');
break;
case 'run':
run_jobs($job_id);
redirect('admin/' . basename(__FILE__) . '?mode=list');
break;
case 'edit':
$sql = DB()->fetch_rowset("SELECT * FROM ". BB_CRON ." WHERE cron_id = $job_id");
case 'edit':
$sql = DB()->fetch_rowset("SELECT * FROM " . BB_CRON . " WHERE cron_id = $job_id");
foreach ($sql as $row)
{
$template->assign_vars(array(
'CRON_ID' => $row['cron_id'],
'CRON_ACTIVE' => $row['cron_active'],
'CRON_TITLE' => $row['cron_title'],
'CRON_SCRIPT' => $row['cron_script'],
'SCHEDULE' => $row['schedule'] ? $lang['SCHEDULE'][$row['schedule']] : '',
'RUN_DAY' => $row['run_day'],
'RUN_TIME' => $row['run_time'],
'RUN_ORDER' => $row['run_order'],
'LAST_RUN' => $row['last_run'],
'NEXT_RUN' => $row['next_run'],
'RUN_INTERVAL' => $row['run_interval'],
'LOG_ENABLED' => $row['log_enabled'],
'LOG_FILE' => $row['log_file'],
'LOG_SQL_QUERIES' => $row['log_sql_queries'],
'DISABLE_BOARD' => $row['disable_board'],
'RUN_COUNTER' => $row['run_counter'],
));
}
foreach ($sql as $row) {
$template->assign_vars(array(
'CRON_ID' => $row['cron_id'],
'CRON_ACTIVE' => $row['cron_active'],
'CRON_TITLE' => $row['cron_title'],
'CRON_SCRIPT' => $row['cron_script'],
'SCHEDULE' => $row['schedule'] ? $lang['SCHEDULE'][$row['schedule']] : '',
'RUN_DAY' => $row['run_day'],
'RUN_TIME' => $row['run_time'],
'RUN_ORDER' => $row['run_order'],
'LAST_RUN' => $row['last_run'],
'NEXT_RUN' => $row['next_run'],
'RUN_INTERVAL' => $row['run_interval'],
'LOG_ENABLED' => $row['log_enabled'],
'LOG_FILE' => $row['log_file'],
'LOG_SQL_QUERIES' => $row['log_sql_queries'],
'DISABLE_BOARD' => $row['disable_board'],
'RUN_COUNTER' => $row['run_counter'],
));
}
$run_day = array($lang['DELTA_TIME']['INTERVALS']['mday'][0] => 0);
for ($i = 1; $i <= 28; $i++)
{
$run_day[$i] = $i;
}
$run_day = array($lang['DELTA_TIME']['INTERVALS']['mday'][0] => 0);
for ($i = 1; $i <= 28; $i++) {
$run_day[$i] = $i;
}
$schedule = array($lang['SCHEDULE']['select'] => 0);
foreach ($lang['SCHEDULE'] as $type => $key)
{
$schedule[$key] = $type;
}
$schedule = array($lang['SCHEDULE']['select'] => 0);
foreach ($lang['SCHEDULE'] as $type => $key) {
$schedule[$key] = $type;
}
$template->assign_vars(array(
'TPL_CRON_EDIT' => true,
'S_CRON_ACTION' => 'admin_cron.php',
'S_MODE' => 'edit',
'SCHEDULE' => build_select('schedule', $schedule, $row['schedule']),
'RUN_DAY' => build_select('run_day', $run_day, $row['run_day']),
'L_CRON_EDIT_HEAD' => $lang['CRON_EDIT_HEAD_EDIT'],
));
break;
$template->assign_vars(array(
'TPL_CRON_EDIT' => true,
'S_CRON_ACTION' => 'admin_cron.php',
'S_MODE' => 'edit',
'SCHEDULE' => build_select('schedule', $schedule, $row['schedule']),
'RUN_DAY' => build_select('run_day', $run_day, $row['run_day']),
'L_CRON_EDIT_HEAD' => $lang['CRON_EDIT_HEAD_EDIT'],
));
break;
case 'add':
$run_day = array($lang['DELTA_TIME']['INTERVALS']['mday'][0] => 0);
for ($i = 1; $i <= 28; $i++)
{
$run_day[$i] = $i;
}
case 'add':
$run_day = array($lang['DELTA_TIME']['INTERVALS']['mday'][0] => 0);
for ($i = 1; $i <= 28; $i++) {
$run_day[$i] = $i;
}
$schedule = array();
foreach ($lang['SCHEDULE'] as $type => $key)
{
$schedule[$key] = $type;
}
$schedule = array();
foreach ($lang['SCHEDULE'] as $type => $key) {
$schedule[$key] = $type;
}
$template->assign_vars(array(
'TPL_CRON_EDIT' => true,
'S_CRON_ACTION' => 'admin_cron.php',
'S_MODE' => 'add',
'SCHEDULE' => build_select('schedule', $schedule, 'select', null, null),
'RUN_DAY' => build_select('run_day', $run_day, 0, null, null),
'L_CRON_EDIT_HEAD' => $lang['CRON_EDIT_HEAD_ADD'],
'CRON_ID' => 'none',
'CRON_ACTIVE' => 1,
'CRON_TITLE' => '',
'CRON_SCRIPT' => '',
'RUN_TIME' => '',
'RUN_ORDER' => 255,
'LAST_RUN' => '0000-00-00 00:00:00',
'NEXT_RUN' => '0000-00-00 00:00:00',
'RUN_INTERVAL' => '',
'LOG_ENABLED' => 0,
'LOG_FILE' => '',
'LOG_SQL_QUERIES' => 0,
'DISABLE_BOARD' => 0,
'RUN_COUNTER' => 0,
));
break;
$template->assign_vars(array(
'TPL_CRON_EDIT' => true,
'S_CRON_ACTION' => 'admin_cron.php',
'S_MODE' => 'add',
'SCHEDULE' => build_select('schedule', $schedule, 'select', null, null),
'RUN_DAY' => build_select('run_day', $run_day, 0, null, null),
'L_CRON_EDIT_HEAD' => $lang['CRON_EDIT_HEAD_ADD'],
'CRON_ID' => 'none',
'CRON_ACTIVE' => 1,
'CRON_TITLE' => '',
'CRON_SCRIPT' => '',
'RUN_TIME' => '',
'RUN_ORDER' => 255,
'LAST_RUN' => '0000-00-00 00:00:00',
'NEXT_RUN' => '0000-00-00 00:00:00',
'RUN_INTERVAL' => '',
'LOG_ENABLED' => 0,
'LOG_FILE' => '',
'LOG_SQL_QUERIES' => 0,
'DISABLE_BOARD' => 0,
'RUN_COUNTER' => 0,
));
break;
case 'delete':
delete_jobs($job_id);
bb_die($lang['JOB_REMOVED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_JOBS'], '<a href="admin_cron.php?mode=list">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
case 'delete':
delete_jobs($job_id);
bb_die($lang['JOB_REMOVED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_JOBS'], '<a href="admin_cron.php?mode=list">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
}
if ($submit)
{
if ($_POST['mode'] == 'list')
{
if ($cron_action == 'run' && $jobs)
{
run_jobs($jobs);
}
else if ($cron_action == 'delete' && $jobs)
{
delete_jobs($jobs);
}
else if (($cron_action == 'disable' || $cron_action == 'enable') && $jobs)
{
toggle_active($jobs, $cron_action);
}
redirect('admin/'.basename(__FILE__) . '?mode=list');
}
else if (validate_cron_post($_POST) == 1)
{
if ($_POST['mode'] == 'edit')
{
update_cron_job($_POST);
}
else if ($_POST['mode'] == 'add')
{
insert_cron_job($_POST);
}
else bb_die('Mode error');
if ($submit) {
if ($_POST['mode'] == 'list') {
if ($cron_action == 'run' && $jobs) {
run_jobs($jobs);
} elseif ($cron_action == 'delete' && $jobs) {
delete_jobs($jobs);
} elseif (($cron_action == 'disable' || $cron_action == 'enable') && $jobs) {
toggle_active($jobs, $cron_action);
}
redirect('admin/' . basename(__FILE__) . '?mode=list');
} elseif (validate_cron_post($_POST) == 1) {
if ($_POST['mode'] == 'edit') {
update_cron_job($_POST);
} elseif ($_POST['mode'] == 'add') {
insert_cron_job($_POST);
} else {
bb_die('Mode error');
}
redirect('admin/'.basename(__FILE__) . '?mode=list');
}
else
{
bb_die(validate_cron_post($_POST));
}
redirect('admin/' . basename(__FILE__) . '?mode=list');
} else {
bb_die(validate_cron_post($_POST));
}
}
print_page('admin_cron.tpl', 'admin');
print_page('admin_cron.tpl', 'admin');

View file

@ -1,58 +1,70 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['USERS']['DISALLOW'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['USERS']['DISALLOW'] = basename(__FILE__);
return;
}
require('./pagestart.php');
$message = '';
if (isset($_POST['add_name']))
{
include(INC_DIR .'functions_validate.php');
if (isset($_POST['add_name'])) {
include(INC_DIR . 'functions_validate.php');
$disallowed_user = ( isset($_POST['disallowed_user']) ) ? trim($_POST['disallowed_user']) : trim($_GET['disallowed_user']);
$disallowed_user = (isset($_POST['disallowed_user'])) ? trim($_POST['disallowed_user']) : trim($_GET['disallowed_user']);
if ($disallowed_user == '')
{
bb_die($lang['FIELDS_EMPTY']);
}
if( !validate_username($disallowed_user) )
{
$message = $lang['DISALLOWED_ALREADY'];
}
else
{
$sql = "INSERT INTO " . BB_DISALLOW . " (disallow_username) VALUES('" . DB()->escape($disallowed_user) . "')";
$result = DB()->sql_query( $sql );
if (!$result)
{
bb_die('Could not add disallowed user');
}
$message = $lang['DISALLOW_SUCCESSFUL'];
}
if ($disallowed_user == '') {
bb_die($lang['FIELDS_EMPTY']);
}
if (!validate_username($disallowed_user)) {
$message = $lang['DISALLOWED_ALREADY'];
} else {
$sql = "INSERT INTO " . BB_DISALLOW . " (disallow_username) VALUES('" . DB()->escape($disallowed_user) . "')";
$result = DB()->sql_query($sql);
if (!$result) {
bb_die('Could not add disallowed user');
}
$message = $lang['DISALLOW_SUCCESSFUL'];
}
$message .= '<br /><br />'. sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') . '<br /><br />'. sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$message .= '<br /><br />' . sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
elseif (isset($_POST['delete_name']))
{
$disallowed_id = (isset($_POST['disallowed_id']) ) ? intval( $_POST['disallowed_id'] ) : intval( $_GET['disallowed_id']);
bb_die($message);
} elseif (isset($_POST['delete_name'])) {
$disallowed_id = (isset($_POST['disallowed_id'])) ? intval($_POST['disallowed_id']) : intval($_GET['disallowed_id']);
$sql = "DELETE FROM " . BB_DISALLOW . " WHERE disallow_id = $disallowed_id";
$result = DB()->sql_query($sql);
if (!$result)
{
bb_die('Could not removed disallowed user');
}
$sql = "DELETE FROM " . BB_DISALLOW . " WHERE disallow_id = $disallowed_id";
$result = DB()->sql_query($sql);
if (!$result) {
bb_die('Could not removed disallowed user');
}
$message .= $lang['DISALLOWED_DELETED'] .'<br /><br />'. sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') .'<br /><br />'. sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
$message .= $lang['DISALLOWED_DELETED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
//
@ -60,9 +72,8 @@ elseif (isset($_POST['delete_name']))
//
$sql = "SELECT * FROM " . BB_DISALLOW;
$result = DB()->sql_query($sql);
if (!$result)
{
bb_die('Could not get disallowed users');
if (!$result) {
bb_die('Could not get disallowed users');
}
$disallowed = DB()->sql_fetchrowset($result);
@ -73,23 +84,19 @@ $disallowed = DB()->sql_fetchrowset($result);
//
$disallow_select = '<select name="disallowed_id">';
if (count($disallowed) <= 0)
{
$disallow_select .= '<option value="">' . $lang['NO_DISALLOWED'] . '</option>';
}
else
{
for ($i = 0; $i < count($disallowed); $i++)
{
$disallow_select .= '<option value="' . $disallowed[$i]['disallow_id'] . '">' . $disallowed[$i]['disallow_username'] . '</option>';
}
if (count($disallowed) <= 0) {
$disallow_select .= '<option value="">' . $lang['NO_DISALLOWED'] . '</option>';
} else {
for ($i = 0; $i < count($disallowed); $i++) {
$disallow_select .= '<option value="' . $disallowed[$i]['disallow_id'] . '">' . $disallowed[$i]['disallow_username'] . '</option>';
}
}
$disallow_select .= '</select>';
$template->assign_vars(array(
'S_DISALLOW_SELECT' => $disallow_select,
'S_FORM_ACTION' => 'admin_disallow.php',
'S_DISALLOW_SELECT' => $disallow_select,
'S_FORM_ACTION' => 'admin_disallow.php',
));
print_page('admin_disallow.tpl', 'admin');
print_page('admin_disallow.tpl', 'admin');

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,31 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['FORUMS']['PRUNE'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['FORUMS']['PRUNE'] = basename(__FILE__);
return;
}
require('./pagestart.php');
@ -11,50 +33,44 @@ $all_forums = -1;
$pruned_total = 0;
$prune_performed = false;
if (isset($_REQUEST['submit']))
{
if (!$var =& $_REQUEST['f'] OR !$f_selected = get_id_ary($var))
{
bb_die('Forum not selected');
}
if (!$var =& $_REQUEST['prunedays'] OR !$prunedays = abs(intval($var)))
{
bb_die($lang['NOT_DAYS']);
}
if (isset($_REQUEST['submit'])) {
if (!$var =& $_REQUEST['f'] or !$f_selected = get_id_ary($var)) {
bb_die('Forum not selected');
}
if (!$var =& $_REQUEST['prunedays'] or !$prunedays = abs(intval($var))) {
bb_die($lang['NOT_DAYS']);
}
$prunetime = TIMENOW - 86400*$prunedays;
$forum_csv = in_array($all_forums, $f_selected) ? $all_forums : join(',', $f_selected);
$prunetime = TIMENOW - 86400 * $prunedays;
$forum_csv = in_array($all_forums, $f_selected) ? $all_forums : join(',', $f_selected);
$where_sql = ($forum_csv != $all_forums) ? "WHERE forum_id IN($forum_csv)" : '';
$where_sql = ($forum_csv != $all_forums) ? "WHERE forum_id IN($forum_csv)" : '';
$sql = "SELECT forum_id, forum_name FROM ". BB_FORUMS ." $where_sql";
$sql = "SELECT forum_id, forum_name FROM " . BB_FORUMS . " $where_sql";
foreach (DB()->fetch_rowset($sql) as $i => $row)
{
$pruned_topics = topic_delete('prune', $row['forum_id'], $prunetime, !empty($_POST['prune_all_topic_types']));
$pruned_total += $pruned_topics;
$prune_performed = true;
foreach (DB()->fetch_rowset($sql) as $i => $row) {
$pruned_topics = topic_delete('prune', $row['forum_id'], $prunetime, !empty($_POST['prune_all_topic_types']));
$pruned_total += $pruned_topics;
$prune_performed = true;
$template->assign_block_vars('pruned', array(
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'FORUM_NAME' => htmlCHR($row['forum_name']),
'PRUNED_TOPICS' => $pruned_topics,
));
}
if (!$prune_performed)
{
bb_die($lang['NONE_SELECTED']);
}
if (!$pruned_total)
{
bb_die($lang['NO_SEARCH_MATCH']);
}
$template->assign_block_vars('pruned', array(
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'FORUM_NAME' => htmlCHR($row['forum_name']),
'PRUNED_TOPICS' => $pruned_topics,
));
}
if (!$prune_performed) {
bb_die($lang['NONE_SELECTED']);
}
if (!$pruned_total) {
bb_die($lang['NO_SEARCH_MATCH']);
}
}
$template->assign_vars(array(
'PRUNED_TOTAL' => $pruned_total,
'S_PRUNE_ACTION' => basename(__FILE__),
'SEL_FORUM' => get_forum_select('admin', 'f[]', null, 65, 16, '', $all_forums),
'PRUNED_TOTAL' => $pruned_total,
'S_PRUNE_ACTION' => basename(__FILE__),
'SEL_FORUM' => get_forum_select('admin', 'f[]', null, 65, 16, '', $all_forums),
));
print_page('admin_forum_prune.tpl', 'admin');
print_page('admin_forum_prune.tpl', 'admin');

View file

@ -1,135 +1,144 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['FORUMS']['PERMISSIONS'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['FORUMS']['PERMISSIONS'] = basename(__FILE__);
return;
}
require('./pagestart.php');
$forum_auth_fields = array(
'auth_view',
'auth_read',
'auth_reply',
'auth_edit',
'auth_delete',
'auth_vote',
'auth_pollcreate',
'auth_attachments',
'auth_download',
'auth_post',
'auth_sticky',
'auth_announce',
'auth_view',
'auth_read',
'auth_reply',
'auth_edit',
'auth_delete',
'auth_vote',
'auth_pollcreate',
'auth_attachments',
'auth_download',
'auth_post',
'auth_sticky',
'auth_announce',
);
// View Read Reply Edit Delete Vote Poll PostAttach DownAttach PostTopic Sticky Announce
$simple_auth_ary = array(
/* Public */ 0 => array(AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL, AUTH_ALL, AUTH_MOD, AUTH_MOD), // Public
/* Reg */ 1 => array(AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD), // Registered
/* Reg [Hid] */ 2 => array(AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD), // Registered [Hidden]
/* Priv */ 3 => array(AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD), // Private
/* Priv [Hid] */ 4 => array(AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD), // Private [Hidden]
/* MOD */ 5 => array(AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators
/* MOD [Hid] */ 6 => array(AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators [Hidden]
/* Public */
0 => array(AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL, AUTH_ALL, AUTH_MOD, AUTH_MOD), // Public
/* Reg */
1 => array(AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD), // Registered
/* Reg [Hid] */
2 => array(AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD), // Registered [Hidden]
/* Priv */
3 => array(AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD), // Private
/* Priv [Hid] */
4 => array(AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD), // Private [Hidden]
/* MOD */
5 => array(AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators
/* MOD [Hid] */
6 => array(AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators [Hidden]
);
$simple_auth_types = array(
$lang['PUBLIC'],
$lang['REGISTERED'],
$lang['REGISTERED'] .' ['. $lang['HIDDEN'] .']',
$lang['PRIVATE'],
$lang['PRIVATE'] .' ['. $lang['HIDDEN'] .']',
$lang['MODERATORS'],
$lang['MODERATORS'] .' ['. $lang['HIDDEN'] .']',
$lang['PUBLIC'],
$lang['REGISTERED'],
$lang['REGISTERED'] . ' [' . $lang['HIDDEN'] . ']',
$lang['PRIVATE'],
$lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']',
$lang['MODERATORS'],
$lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']',
);
$field_names = array();
foreach ($forum_auth_fields as $auth_type)
{
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
foreach ($forum_auth_fields as $auth_type) {
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
}
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
if (@$_REQUEST[POST_FORUM_URL])
{
$forum_id = (int) $_REQUEST[POST_FORUM_URL];
$forum_sql = "WHERE forum_id = $forum_id";
}
else
{
unset($forum_id);
$forum_sql = '';
if (@$_REQUEST[POST_FORUM_URL]) {
$forum_id = (int)$_REQUEST[POST_FORUM_URL];
$forum_sql = "WHERE forum_id = $forum_id";
} else {
unset($forum_id);
$forum_sql = '';
}
if( isset($_GET['adv']) )
{
$adv = intval($_GET['adv']);
}
else
{
unset($adv);
if (isset($_GET['adv'])) {
$adv = intval($_GET['adv']);
} else {
unset($adv);
}
//
// Start program proper
//
if( isset($_POST['submit']) )
{
$sql = '';
if (isset($_POST['submit'])) {
$sql = '';
if(!empty($forum_id))
{
if(isset($_POST['simpleauth']))
{
$simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])];
if (!empty($forum_id)) {
if (isset($_POST['simpleauth'])) {
$simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])];
for($i = 0; $i < count($simple_ary); $i++)
{
$sql .= ( ( $sql != '' ) ? ', ' : '' ) . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
for ($i = 0; $i < count($simple_ary); $i++) {
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
if (is_array($simple_ary))
{
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
}
else
{
for ($i = 0; $i < count($forum_auth_fields); $i++)
{
$value = intval($_POST[$forum_auth_fields[$i]]);
if (is_array($simple_ary)) {
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
} else {
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$value = intval($_POST[$forum_auth_fields[$i]]);
if ($forum_auth_fields[$i] == 'auth_vote')
{
if ($_POST['auth_vote'] == AUTH_ALL)
{
$value = AUTH_REG;
}
}
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
$value = AUTH_REG;
}
}
$sql .= ( ( $sql != '' ) ? ', ' : '' ) .$forum_auth_fields[$i] . ' = ' . $value;
}
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $value;
}
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
if ($sql != '')
{
if (!DB()->sql_query($sql))
{
bb_die('Could not update auth table');
}
}
if ($sql != '') {
if (!DB()->sql_query($sql)) {
bb_die('Could not update auth table');
}
}
$forum_sql = '';
$adv = 0;
}
$datastore->update('cat_forums');
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="'."admin_forumauth.php".'">', "</a>"));
$forum_sql = '';
$adv = 0;
}
$datastore->update('cat_forums');
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="' . "admin_forumauth.php" . '">', "</a>"));
} // End of submit
//
@ -137,116 +146,101 @@ if( isset($_POST['submit']) )
// no id was specified or just the requsted if it
// was
//
$forum_rows = DB()->fetch_rowset("SELECT * FROM ". BB_FORUMS ." $forum_sql");
$forum_rows = DB()->fetch_rowset("SELECT * FROM " . BB_FORUMS . " $forum_sql");
if (empty($forum_id))
{
// Output the selection table if no forum id was specified
$template->assign_vars(array(
'TPL_AUTH_SELECT_FORUM' => true,
'S_AUTH_ACTION' => 'admin_forumauth.php',
'S_AUTH_SELECT' => get_forum_select('admin', 'f', null, 80),
));
if (empty($forum_id)) {
// Output the selection table if no forum id was specified
$template->assign_vars(array(
'TPL_AUTH_SELECT_FORUM' => true,
'S_AUTH_ACTION' => 'admin_forumauth.php',
'S_AUTH_SELECT' => get_forum_select('admin', 'f', null, 80),
));
} else {
// Output the authorisation details if an id was specified
$forum_name = $forum_rows[0]['forum_name'];
}
else
{
// Output the authorisation details if an id was specified
$forum_name = $forum_rows[0]['forum_name'];
@reset($simple_auth_ary);
while (list($key, $auth_levels) = each($simple_auth_ary)) {
$matched = 1;
for ($k = 0; $k < count($auth_levels); $k++) {
$matched_type = $key;
@reset($simple_auth_ary);
while (list($key, $auth_levels) = each($simple_auth_ary))
{
$matched = 1;
for ($k = 0; $k < count($auth_levels); $k++)
{
$matched_type = $key;
if ($forum_rows[0][$forum_auth_fields[$k]] != $auth_levels[$k]) {
$matched = 0;
}
}
if ($forum_rows[0][$forum_auth_fields[$k]] != $auth_levels[$k])
{
$matched = 0;
}
}
if ($matched) {
break;
}
}
if ( $matched )
{
break;
}
}
//
// If we didn't get a match above then we
// automatically switch into 'advanced' mode
//
if (!isset($adv) && !$matched) {
$adv = 1;
}
//
// If we didn't get a match above then we
// automatically switch into 'advanced' mode
//
if ( !isset($adv) && !$matched )
{
$adv = 1;
}
$s_column_span = 0;
$s_column_span = 0;
if (empty($adv)) {
$simple_auth = '<select name="simpleauth">';
if (empty($adv))
{
$simple_auth = '<select name="simpleauth">';
for ($j = 0; $j < count($simple_auth_types); $j++) {
$selected = ($matched_type == $j) ? ' selected="selected"' : '';
$simple_auth .= '<option value="' . $j . '"' . $selected . '>' . $simple_auth_types[$j] . '</option>';
}
for($j = 0; $j < count($simple_auth_types); $j++)
{
$selected = ( $matched_type == $j ) ? ' selected="selected"' : '';
$simple_auth .= '<option value="' . $j . '"' . $selected . '>' . $simple_auth_types[$j] . '</option>';
}
$simple_auth .= '</select>';
$simple_auth .= '</select>';
$template->assign_block_vars('forum_auth', array(
'CELL_TITLE' => $lang['SIMPLE_MODE'],
'S_AUTH_LEVELS_SELECT' => $simple_auth,
));
$template->assign_block_vars('forum_auth', array(
'CELL_TITLE' => $lang['SIMPLE_MODE'],
'S_AUTH_LEVELS_SELECT' => $simple_auth,
));
$s_column_span++;
} else {
//
// Output values of individual
// fields
//
for ($j = 0; $j < count($forum_auth_fields); $j++) {
$custom_auth[$j] = '&nbsp;<select name="' . $forum_auth_fields[$j] . '">';
$s_column_span++;
}
else
{
//
// Output values of individual
// fields
//
for ($j = 0; $j < count($forum_auth_fields); $j++)
{
$custom_auth[$j] = '&nbsp;<select name="' . $forum_auth_fields[$j] . '">';
for ($k = 0; $k < count($forum_auth_levels); $k++) {
$selected = ($forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k]) ? ' selected="selected"' : '';
$custom_auth[$j] .= '<option value="' . $forum_auth_const[$k] . '"' . $selected . '>' . $lang['FORUM_' . strtoupper($forum_auth_levels[$k])] . '</OPTION>';
}
$custom_auth[$j] .= '</select>&nbsp;';
for ($k = 0; $k < count($forum_auth_levels); $k++)
{
$selected = ( $forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k] ) ? ' selected="selected"' : '';
$custom_auth[$j] .= '<option value="' . $forum_auth_const[$k] . '"' . $selected . '>' . $lang['FORUM_' . strtoupper($forum_auth_levels[$k])] . '</OPTION>';
}
$custom_auth[$j] .= '</select>&nbsp;';
$cell_title = $field_names[$forum_auth_fields[$j]];
$cell_title = $field_names[$forum_auth_fields[$j]];
$template->assign_block_vars('forum_auth', array(
'CELL_TITLE' => $cell_title,
'S_AUTH_LEVELS_SELECT' => $custom_auth[$j],
));
$template->assign_block_vars('forum_auth', array(
'CELL_TITLE' => $cell_title,
'S_AUTH_LEVELS_SELECT' => $custom_auth[$j],
));
$s_column_span++;
}
}
$s_column_span++;
}
}
$adv_mode = (empty($adv)) ? '1' : '0';
$switch_mode = "admin_forumauth.php?f=$forum_id&amp;adv=$adv_mode";
$switch_mode_text = (empty($adv)) ? $lang['ADVANCED_MODE'] : $lang['SIMPLE_MODE'];
$u_switch_mode = '<a href="' . $switch_mode . '">' . $switch_mode_text . '</a>';
$adv_mode = ( empty($adv) ) ? '1' : '0';
$switch_mode = "admin_forumauth.php?f=$forum_id&amp;adv=$adv_mode";
$switch_mode_text = ( empty($adv) ) ? $lang['ADVANCED_MODE'] : $lang['SIMPLE_MODE'];
$u_switch_mode = '<a href="' . $switch_mode . '">' . $switch_mode_text . '</a>';
$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';
$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';
$template->assign_vars(array(
'TPL_EDIT_FORUM_AUTH' => true,
'FORUM_NAME' => htmlCHR($forum_name),
'U_SWITCH_MODE' => $u_switch_mode,
'S_FORUMAUTH_ACTION' => 'admin_forumauth.php',
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
$template->assign_vars(array(
'TPL_EDIT_FORUM_AUTH' => true,
'FORUM_NAME' => htmlCHR($forum_name),
'U_SWITCH_MODE' => $u_switch_mode,
'S_FORUMAUTH_ACTION' => 'admin_forumauth.php',
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
print_page('admin_forumauth.tpl', 'admin');
print_page('admin_forumauth.tpl', 'admin');

View file

@ -1,175 +1,174 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['FORUMS']['PERMISSIONS_LIST'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['FORUMS']['PERMISSIONS_LIST'] = basename(__FILE__);
return;
}
require('./pagestart.php');
// View Read Post Reply Edit Delete Sticky Announce Vote Poll PostAttach Download
$simple_auth_ary = array(
/* Public */ 0 => array(AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL), // Public
/* Reg */ 1 => array(AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG), // Registered
/* Reg [Hid] */ 2 => array(AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG), // Registered [Hidden]
/* Priv */ 3 => array(AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL), // Private
/* Priv [Hid] */ 4 => array(AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL), // Private [Hidden]
/* MOD */ 5 => array(AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators
/* MOD [Hid] */ 6 => array(AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators [Hidden]
/* Public */
0 => array(AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_ALL), // Public
/* Reg */
1 => array(AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG), // Registered
/* Reg [Hid] */
2 => array(AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG), // Registered [Hidden]
/* Priv */
3 => array(AUTH_REG, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL), // Private
/* Priv [Hid] */
4 => array(AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_MOD, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL), // Private [Hidden]
/* MOD */
5 => array(AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators
/* MOD [Hid] */
6 => array(AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), // Moderators [Hidden]
);
$simple_auth_types = array(
$lang['PUBLIC'],
$lang['REGISTERED'],
$lang['REGISTERED'] .' ['. $lang['HIDDEN'] .']',
$lang['PRIVATE'],
$lang['PRIVATE'] .' ['. $lang['HIDDEN'] .']',
$lang['MODERATORS'],
$lang['MODERATORS'] .' ['. $lang['HIDDEN'] .']',
$lang['PUBLIC'],
$lang['REGISTERED'],
$lang['REGISTERED'] . ' [' . $lang['HIDDEN'] . ']',
$lang['PRIVATE'],
$lang['PRIVATE'] . ' [' . $lang['HIDDEN'] . ']',
$lang['MODERATORS'],
$lang['MODERATORS'] . ' [' . $lang['HIDDEN'] . ']',
);
$forum_auth_fields = array(
'auth_view',
'auth_read',
'auth_reply',
'auth_edit',
'auth_delete',
'auth_vote',
'auth_pollcreate',
'auth_attachments',
'auth_download',
'auth_post',
'auth_sticky',
'auth_announce',
'auth_view',
'auth_read',
'auth_reply',
'auth_edit',
'auth_delete',
'auth_vote',
'auth_pollcreate',
'auth_attachments',
'auth_download',
'auth_post',
'auth_sticky',
'auth_announce',
);
$field_names = array();
foreach ($forum_auth_fields as $auth_type)
{
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
foreach ($forum_auth_fields as $auth_type) {
$field_names[$auth_type] = $lang[strtoupper($auth_type)];
}
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
if(isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL]))
{
$forum_id = (isset($_POST[POST_FORUM_URL])) ? intval($_POST[POST_FORUM_URL]) : intval($_GET[POST_FORUM_URL]);
$forum_sql = "AND forum_id = $forum_id";
}
else
{
unset($forum_id);
$forum_sql = '';
if (isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL])) {
$forum_id = (isset($_POST[POST_FORUM_URL])) ? intval($_POST[POST_FORUM_URL]) : intval($_GET[POST_FORUM_URL]);
$forum_sql = "AND forum_id = $forum_id";
} else {
unset($forum_id);
$forum_sql = '';
}
if(isset($_GET[POST_CAT_URL]) || isset($_POST[POST_CAT_URL]))
{
$cat_id = (isset($_POST[POST_CAT_URL])) ? intval($_POST[POST_CAT_URL]) : intval($_GET[POST_CAT_URL]);
$cat_sql = "AND c.cat_id = $cat_id";
}
else
{
unset($cat_id);
$cat_sql = '';
if (isset($_GET[POST_CAT_URL]) || isset($_POST[POST_CAT_URL])) {
$cat_id = (isset($_POST[POST_CAT_URL])) ? intval($_POST[POST_CAT_URL]) : intval($_GET[POST_CAT_URL]);
$cat_sql = "AND c.cat_id = $cat_id";
} else {
unset($cat_id);
$cat_sql = '';
}
if( isset($_GET['adv']) )
{
$adv = intval($_GET['adv']);
}
else
{
unset($adv);
if (isset($_GET['adv'])) {
$adv = intval($_GET['adv']);
} else {
unset($adv);
}
//
// Start program proper
//
if( isset($_POST['submit']) )
{
$sql = '';
if (isset($_POST['submit'])) {
$sql = '';
if(!empty($forum_id))
{
if(isset($_POST['simpleauth']))
{
$simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])];
if (!empty($forum_id)) {
if (isset($_POST['simpleauth'])) {
$simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])];
for($i = 0; $i < count($simple_ary); $i++)
{
$sql .= ( ( $sql != '' ) ? ', ' : '' ) . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
for ($i = 0; $i < count($simple_ary); $i++) {
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
if (is_array($simple_ary))
{
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
}
else
{
for($i = 0; $i < count($forum_auth_fields); $i++)
{
$value = intval($_POST[$forum_auth_fields[$i]]);
if (is_array($simple_ary)) {
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
} else {
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$value = intval($_POST[$forum_auth_fields[$i]]);
if ( $forum_auth_fields[$i] == 'auth_vote' )
{
if ( $_POST['auth_vote'] == AUTH_ALL )
{
$value = AUTH_REG;
}
}
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
$value = AUTH_REG;
}
}
$sql .= ( ( $sql != '' ) ? ', ' : '' ) .$forum_auth_fields[$i] . ' = ' . $value;
}
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $value;
}
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
if ($sql != '')
{
if (!DB()->sql_query($sql))
{
bb_die('Could not update auth table #1');
}
}
if ($sql != '') {
if (!DB()->sql_query($sql)) {
bb_die('Could not update auth table #1');
}
}
$forum_sql = '';
$adv = 0;
}
elseif (!empty($cat_id))
{
for ($i = 0; $i < count($forum_auth_fields); $i++)
{
$value = intval($_POST[$forum_auth_fields[$i]]);
$forum_sql = '';
$adv = 0;
} elseif (!empty($cat_id)) {
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$value = intval($_POST[$forum_auth_fields[$i]]);
if ($forum_auth_fields[$i] == 'auth_vote')
{
if ( $_POST['auth_vote'] == AUTH_ALL )
{
$value = AUTH_REG;
}
}
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
$value = AUTH_REG;
}
}
$sql .= ( ( $sql != '' ) ? ', ' : '' ) .$forum_auth_fields[$i] . ' = ' . $value;
}
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $value;
}
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE cat_id = $cat_id";
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE cat_id = $cat_id";
if ($sql != '')
{
if (!DB()->sql_query($sql))
{
bb_die('Could not update auth table #2');
}
}
if ($sql != '') {
if (!DB()->sql_query($sql)) {
bb_die('Could not update auth table #2');
}
}
$cat_sql = '';
}
$datastore->update('cat_forums');
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="admin_forumauth_list.php">', "</a>"));
$cat_sql = '';
}
$datastore->update('cat_forums');
bb_die($lang['FORUM_AUTH_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMAUTH'], '<a href="admin_forumauth_list.php">', "</a>"));
} // End of submit
//
@ -182,182 +181,161 @@ $sql = "SELECT f.*
WHERE c.cat_id = f.cat_id
$forum_sql $cat_sql
ORDER BY c.cat_order ASC, f.forum_order ASC";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not obtain forum list');
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain forum list');
}
$forum_rows = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
if( empty($forum_id) && empty($cat_id) )
{
//
// Output the summary list if no forum id was
// specified
//
$template->assign_vars(array(
'TPL_AUTH_FORUM_LIST' => true,
'S_COLUMN_SPAN' => count($forum_auth_fields)+1,
));
if (empty($forum_id) && empty($cat_id)) {
//
// Output the summary list if no forum id was
// specified
//
$template->assign_vars(array(
'TPL_AUTH_FORUM_LIST' => true,
'S_COLUMN_SPAN' => count($forum_auth_fields) + 1,
));
for ($i = 0; $i<count($forum_auth_fields); $i++)
{
$template->assign_block_vars('forum_auth_titles', array(
'CELL_TITLE' => $field_names[$forum_auth_fields[$i]],
));
}
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$template->assign_block_vars('forum_auth_titles', array(
'CELL_TITLE' => $field_names[$forum_auth_fields[$i]],
));
}
// Obtain the category list
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
// Obtain the category list
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
FROM " . BB_CATEGORIES . " c
ORDER BY c.cat_order";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query categories list #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query categories list #1');
}
$category_rows = DB()->sql_fetchrowset($result);
$cat_count = count($category_rows);
$category_rows = DB()->sql_fetchrowset($result);
$cat_count = count($category_rows);
for ($i=0; $i<$cat_count; $i++)
{
$cat_id = $category_rows[$i]['cat_id'];
for ($i = 0; $i < $cat_count; $i++) {
$cat_id = $category_rows[$i]['cat_id'];
$template->assign_block_vars('cat_row', array(
'CAT_NAME' => htmlCHR($category_rows[$i]['cat_title']),
'CAT_URL' => 'admin_forumauth_list.php'.'?'.POST_CAT_URL.'='.$category_rows[$i]['cat_id'])
);
$template->assign_block_vars('cat_row', array(
'CAT_NAME' => htmlCHR($category_rows[$i]['cat_title']),
'CAT_URL' => 'admin_forumauth_list.php' . '?' . POST_CAT_URL . '=' . $category_rows[$i]['cat_id'])
);
for ($j=0; $j<count($forum_rows); $j++)
{
if ( $cat_id == $forum_rows[$j]['cat_id'] )
{
$template->assign_block_vars('cat_row.forum_row', array(
'ROW_CLASS' => !($j % 2) ? 'row4' : 'row5',
'FORUM_NAME' => '<a class="'.(($forum_rows[$j]['forum_parent']) ? 'genmed' : 'gen').'" href="admin_forumauth.php?'. POST_FORUM_URL .'='. $forum_rows[$j]['forum_id'] .'">'. htmlCHR($forum_rows[$j]['forum_name']) .'</a>',
'IS_SUBFORUM' => $forum_rows[$j]['forum_parent'],
));
for ($j = 0; $j < count($forum_rows); $j++) {
if ($cat_id == $forum_rows[$j]['cat_id']) {
$template->assign_block_vars('cat_row.forum_row', array(
'ROW_CLASS' => !($j % 2) ? 'row4' : 'row5',
'FORUM_NAME' => '<a class="' . (($forum_rows[$j]['forum_parent']) ? 'genmed' : 'gen') . '" href="admin_forumauth.php?' . POST_FORUM_URL . '=' . $forum_rows[$j]['forum_id'] . '">' . htmlCHR($forum_rows[$j]['forum_name']) . '</a>',
'IS_SUBFORUM' => $forum_rows[$j]['forum_parent'],
));
for ($k=0; $k<count($forum_auth_fields); $k++)
{
$item_auth_value = $forum_rows[$j][$forum_auth_fields[$k]];
for ($l=0; $l<count($forum_auth_const); $l++)
{
if ($item_auth_value == $forum_auth_const[$l])
{
$item_auth_level = $forum_auth_levels[$l];
break;
}
}
$template->assign_block_vars('cat_row.forum_row.forum_auth_data', array(
'CELL_VALUE' => $lang['FORUM_' . $item_auth_level],
'AUTH_EXPLAIN' => sprintf($lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $forum_auth_fields[$k])], $lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $item_auth_level)]))
);
}
}
}
}
}
else
{
//
// output the authorisation details if an category id was
// specified
//
for ($k = 0; $k < count($forum_auth_fields); $k++) {
$item_auth_value = $forum_rows[$j][$forum_auth_fields[$k]];
for ($l = 0; $l < count($forum_auth_const); $l++) {
if ($item_auth_value == $forum_auth_const[$l]) {
$item_auth_level = $forum_auth_levels[$l];
break;
}
}
$template->assign_block_vars('cat_row.forum_row.forum_auth_data', array(
'CELL_VALUE' => $lang['FORUM_' . $item_auth_level],
'AUTH_EXPLAIN' => sprintf($lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $forum_auth_fields[$k])], $lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $item_auth_level)]))
);
}
}
}
}
} else {
//
// output the authorisation details if an category id was
// specified
//
//
// first display the current details for all forums
// in the category
//
for ($i = 0; $i<count($forum_auth_fields); $i++)
{
$template->assign_block_vars('forum_auth_titles', array(
'CELL_TITLE' => $field_names[$forum_auth_fields[$i]],
));
}
//
// first display the current details for all forums
// in the category
//
for ($i = 0; $i < count($forum_auth_fields); $i++) {
$template->assign_block_vars('forum_auth_titles', array(
'CELL_TITLE' => $field_names[$forum_auth_fields[$i]],
));
}
// obtain the category list
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
// obtain the category list
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
FROM " . BB_CATEGORIES . " c
WHERE c.cat_id = $cat_id
ORDER BY c.cat_order";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query categories list #2');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query categories list #2');
}
$category_rows = DB()->sql_fetchrowset($result);
$category_rows = DB()->sql_fetchrowset($result);
$cat_id = $category_rows[0]['cat_id'];
$cat_name = $category_rows[0]['cat_title'];
$cat_id = $category_rows[0]['cat_id'];
$cat_name = $category_rows[0]['cat_title'];
$template->assign_block_vars('cat_row', array(
'CAT_NAME' => htmlCHR($cat_name),
'CAT_URL' => 'admin_forumauth_list.php?'. POST_CAT_URL .'='. $cat_id)
);
$template->assign_block_vars('cat_row', array(
'CAT_NAME' => htmlCHR($cat_name),
'CAT_URL' => 'admin_forumauth_list.php?' . POST_CAT_URL . '=' . $cat_id)
);
for ($j=0; $j<count($forum_rows); $j++)
{
if ( $cat_id == $forum_rows[$j]['cat_id'] )
{
$template->assign_block_vars('cat_row.forum_row', array(
'ROW_CLASS' => !($j % 2) ? 'row4' : 'row5',
'FORUM_NAME' => '<a class="'.(($forum_rows[$j]['forum_parent']) ? 'genmed' : 'gen').'" href="admin_forumauth.php?'. POST_FORUM_URL .'='. $forum_rows[$j]['forum_id'] .'">'. htmlCHR($forum_rows[$j]['forum_name']) .'</a>',
'IS_SUBFORUM' => $forum_rows[$j]['forum_parent'],
));
for ($j = 0; $j < count($forum_rows); $j++) {
if ($cat_id == $forum_rows[$j]['cat_id']) {
$template->assign_block_vars('cat_row.forum_row', array(
'ROW_CLASS' => !($j % 2) ? 'row4' : 'row5',
'FORUM_NAME' => '<a class="' . (($forum_rows[$j]['forum_parent']) ? 'genmed' : 'gen') . '" href="admin_forumauth.php?' . POST_FORUM_URL . '=' . $forum_rows[$j]['forum_id'] . '">' . htmlCHR($forum_rows[$j]['forum_name']) . '</a>',
'IS_SUBFORUM' => $forum_rows[$j]['forum_parent'],
));
for ($k=0; $k<count($forum_auth_fields); $k++)
{
$item_auth_value = $forum_rows[$j][$forum_auth_fields[$k]];
for ($l=0; $l<count($forum_auth_const); $l++)
{
if ($item_auth_value == $forum_auth_const[$l])
{
$item_auth_level = $forum_auth_levels[$l];
break;
}
}
$template->assign_block_vars('cat_row.forum_row.forum_auth_data', array(
'CELL_VALUE' => $lang['FORUM_' . $item_auth_level],
'AUTH_EXPLAIN' => sprintf($lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $forum_auth_fields[$k])], $lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $item_auth_level)]))
);
}
}
}
for ($k = 0; $k < count($forum_auth_fields); $k++) {
$item_auth_value = $forum_rows[$j][$forum_auth_fields[$k]];
for ($l = 0; $l < count($forum_auth_const); $l++) {
if ($item_auth_value == $forum_auth_const[$l]) {
$item_auth_level = $forum_auth_levels[$l];
break;
}
}
$template->assign_block_vars('cat_row.forum_row.forum_auth_data', array(
'CELL_VALUE' => $lang['FORUM_' . $item_auth_level],
'AUTH_EXPLAIN' => sprintf($lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $forum_auth_fields[$k])], $lang[strtoupper('FORUM_AUTH_LIST_EXPLAIN_' . $item_auth_level)]))
);
}
}
}
//
// next generate the information to allow the permissions to be changed
// note: we always read from the first forum in the category
//
for($j = 0; $j < count($forum_auth_fields); $j++)
{
$custom_auth[$j] = '<select name="' . $forum_auth_fields[$j] . '">';
//
// next generate the information to allow the permissions to be changed
// note: we always read from the first forum in the category
//
for ($j = 0; $j < count($forum_auth_fields); $j++) {
$custom_auth[$j] = '<select name="' . $forum_auth_fields[$j] . '">';
for($k = 0; $k < count($forum_auth_levels); $k++)
{
$selected = ( !empty($forum_rows) && $forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k] ) ? ' selected="selected"' : '';
$custom_auth[$j] .= '<option value="' . $forum_auth_const[$k] . '"' . $selected . '>' . $lang['FORUM_' . $forum_auth_levels[$k]] . '</option>';
}
$custom_auth[$j] .= '</select>';
for ($k = 0; $k < count($forum_auth_levels); $k++) {
$selected = (!empty($forum_rows) && $forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k]) ? ' selected="selected"' : '';
$custom_auth[$j] .= '<option value="' . $forum_auth_const[$k] . '"' . $selected . '>' . $lang['FORUM_' . $forum_auth_levels[$k]] . '</option>';
}
$custom_auth[$j] .= '</select>';
$template->assign_block_vars('forum_auth_data', array(
'S_AUTH_LEVELS_SELECT' => $custom_auth[$j])
);
}
$template->assign_block_vars('forum_auth_data', array(
'S_AUTH_LEVELS_SELECT' => $custom_auth[$j])
);
}
//
// finally pass any remaining items to the template
//
$s_hidden_fields = '<input type="hidden" name="' . POST_CAT_URL . '" value="' . $cat_id . '">';
//
// finally pass any remaining items to the template
//
$s_hidden_fields = '<input type="hidden" name="' . POST_CAT_URL . '" value="' . $cat_id . '">';
$template->assign_vars(array(
'TPL_AUTH_CAT' => true,
'CAT_NAME' => htmlCHR($cat_name),
'S_FORUMAUTH_ACTION' => 'admin_forumauth_list.php',
'S_COLUMN_SPAN' => count($forum_auth_fields) + 1,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
$template->assign_vars(array(
'TPL_AUTH_CAT' => true,
'CAT_NAME' => htmlCHR($cat_name),
'S_FORUMAUTH_ACTION' => 'admin_forumauth_list.php',
'S_COLUMN_SPAN' => count($forum_auth_fields) + 1,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
print_page('admin_forumauth_list.tpl', 'admin');
print_page('admin_forumauth_list.tpl', 'admin');

File diff suppressed because it is too large Load diff

View file

@ -1,188 +1,185 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['GROUPS']['MANAGE'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['GROUPS']['MANAGE'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require(INC_DIR .'functions_group.php');
require(INC_DIR . 'functions_group.php');
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : 0;
$mode = isset($_REQUEST['mode']) ? strval($_REQUEST['mode']) : '';
$mode = isset($_REQUEST['mode']) ? strval($_REQUEST['mode']) : '';
attachment_quota_settings('group', isset($_POST['group_update']), $mode);
if (!empty($_POST['edit']) || !empty($_POST['new']))
{
if (!empty($_POST['edit']))
{
if (!$row = get_group_data($group_id))
{
bb_die($lang['GROUP_NOT_EXIST']);
}
$group_info = array(
'group_name' => $row['group_name'],
'group_description' => $row['group_description'],
'group_moderator' => $row['group_moderator'],
'group_mod_name' => $row['moderator_name'],
'group_type' => $row['group_type'],
'release_group' => $row['release_group'],
);
$mode = 'editgroup';
$template->assign_block_vars('group_edit', array());
}
else if (!empty($_POST['new']))
{
$group_info = array(
'group_name' => '',
'group_description' => '',
'group_moderator' => '',
'group_mod_name' => '',
'group_type' => GROUP_OPEN,
'release_group' => 0,
);
$mode = 'newgroup';
}
if (!empty($_POST['edit']) || !empty($_POST['new'])) {
if (!empty($_POST['edit'])) {
if (!$row = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
$group_info = array(
'group_name' => $row['group_name'],
'group_description' => $row['group_description'],
'group_moderator' => $row['group_moderator'],
'group_mod_name' => $row['moderator_name'],
'group_type' => $row['group_type'],
'release_group' => $row['release_group'],
);
$mode = 'editgroup';
$template->assign_block_vars('group_edit', array());
} elseif (!empty($_POST['new'])) {
$group_info = array(
'group_name' => '',
'group_description' => '',
'group_moderator' => '',
'group_mod_name' => '',
'group_type' => GROUP_OPEN,
'release_group' => 0,
);
$mode = 'newgroup';
}
// Ok, now we know everything about them, let's show the page.
$s_hidden_fields = '
<input type="hidden" name="mode" value="'. $mode .'" />
<input type="hidden" name="'. POST_GROUPS_URL .'" value="'. $group_id .'" />
// Ok, now we know everything about them, let's show the page.
$s_hidden_fields = '
<input type="hidden" name="mode" value="' . $mode . '" />
<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />
';
$template->assign_vars(array(
'TPL_EDIT_GROUP' => true,
$template->assign_vars(array(
'TPL_EDIT_GROUP' => true,
'GROUP_NAME' => stripslashes(htmlspecialchars($group_info['group_name'])),
'GROUP_DESCRIPTION' => stripslashes(htmlspecialchars($group_info['group_description'])),
'GROUP_MODERATOR' => replace_quote($group_info['group_mod_name']),
'T_GROUP_EDIT_DELETE' => ($mode == 'newgroup') ? $lang['CREATE_NEW_GROUP'] : $lang['EDIT_GROUP'],
'U_SEARCH_USER' => BB_ROOT ."search.php?mode=searchuser",
'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? HTML_CHECKED : '',
'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? HTML_CHECKED : '',
'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN ) ? HTML_CHECKED : '',
'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
'S_GROUP_ACTION' => "admin_groups.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else if (!empty($_POST['group_update']))
{
if (!empty($_POST['group_delete']))
{
if (!$group_info = get_group_data($group_id))
{
bb_die($lang['GROUP_NOT_EXIST']);
}
// Delete Group
delete_group($group_id);
'GROUP_NAME' => stripslashes(htmlspecialchars($group_info['group_name'])),
'GROUP_DESCRIPTION' => stripslashes(htmlspecialchars($group_info['group_description'])),
'GROUP_MODERATOR' => replace_quote($group_info['group_mod_name']),
'T_GROUP_EDIT_DELETE' => ($mode == 'newgroup') ? $lang['CREATE_NEW_GROUP'] : $lang['EDIT_GROUP'],
'U_SEARCH_USER' => BB_ROOT . "search.php?mode=searchuser",
'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? HTML_CHECKED : '',
'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? HTML_CHECKED : '',
'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? HTML_CHECKED : '',
'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
'S_GROUP_ACTION' => "admin_groups.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
} elseif (!empty($_POST['group_update'])) {
if (!empty($_POST['group_delete'])) {
if (!$group_info = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
// Delete Group
delete_group($group_id);
$message = $lang['DELETED_GROUP'] .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_GROUPSADMIN'], '<a href="admin_groups.php">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$message = $lang['DELETED_GROUP'] . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_GROUPSADMIN'], '<a href="admin_groups.php">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
else
{
$group_type = isset($_POST['group_type']) ? intval($_POST['group_type']) : GROUP_OPEN;
$release_group = isset($_POST['release_group']) ? intval($_POST['release_group']) : 0;
$group_name = isset($_POST['group_name']) ? trim($_POST['group_name']) : '';
$group_desc = isset($_POST['group_description']) ? trim($_POST['group_description']) : '';
$group_moderator = isset($_POST['username']) ? $_POST['username'] : '';
bb_die($message);
} else {
$group_type = isset($_POST['group_type']) ? intval($_POST['group_type']) : GROUP_OPEN;
$release_group = isset($_POST['release_group']) ? intval($_POST['release_group']) : 0;
$group_name = isset($_POST['group_name']) ? trim($_POST['group_name']) : '';
$group_desc = isset($_POST['group_description']) ? trim($_POST['group_description']) : '';
$group_moderator = isset($_POST['username']) ? $_POST['username'] : '';
if ($group_name === '')
{
bb_die($lang['NO_GROUP_NAME']);
}
else if ($group_moderator === '')
{
bb_die($lang['NO_GROUP_MODERATOR']);
}
$this_userdata = get_userdata($group_moderator, true);
if ($group_name === '') {
bb_die($lang['NO_GROUP_NAME']);
} elseif ($group_moderator === '') {
bb_die($lang['NO_GROUP_MODERATOR']);
}
$this_userdata = get_userdata($group_moderator, true);
if (!$group_moderator = $this_userdata['user_id'])
{
bb_die($lang['NO_GROUP_MODERATOR']);
}
if (!$group_moderator = $this_userdata['user_id']) {
bb_die($lang['NO_GROUP_MODERATOR']);
}
$sql_ary = array(
'group_type' => (int) $group_type,
'release_group' => (int) $release_group,
'group_name' => (string) $group_name,
'group_description' => (string) $group_desc,
'group_moderator' => (int) $group_moderator,
'group_single_user' => 0,
);
$sql_ary = array(
'group_type' => (int)$group_type,
'release_group' => (int)$release_group,
'group_name' => (string)$group_name,
'group_description' => (string)$group_desc,
'group_moderator' => (int)$group_moderator,
'group_single_user' => 0,
);
if ($mode == "editgroup")
{
if (!$group_info = get_group_data($group_id))
{
bb_die($lang['GROUP_NOT_EXIST']);
}
if ($mode == "editgroup") {
if (!$group_info = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
if ($group_info['group_moderator'] != $group_moderator)
{
// Create user_group for new group's moderator
add_user_into_group($group_id, $group_moderator);
$sql_ary['mod_time'] = TIMENOW;
if ($group_info['group_moderator'] != $group_moderator) {
// Create user_group for new group's moderator
add_user_into_group($group_id, $group_moderator);
$sql_ary['mod_time'] = TIMENOW;
// Delete old moderator's user_group
if (isset($_POST['delete_old_moderator']))
{
delete_user_group($group_id, $group_info['group_moderator']);
}
}
// Delete old moderator's user_group
if (isset($_POST['delete_old_moderator'])) {
delete_user_group($group_id, $group_info['group_moderator']);
}
}
$sql_args = DB()->build_array('UPDATE', $sql_ary);
$sql_args = DB()->build_array('UPDATE', $sql_ary);
// Update group's data
DB()->query("UPDATE ". BB_GROUPS ." SET $sql_args WHERE group_id = $group_id");
// Update group's data
DB()->query("UPDATE " . BB_GROUPS . " SET $sql_args WHERE group_id = $group_id");
$message = $lang['UPDATED_GROUP'] .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_GROUPSADMIN'], '<a href="admin_groups.php">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$message = $lang['UPDATED_GROUP'] . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_GROUPSADMIN'], '<a href="admin_groups.php">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
else if ($mode == 'newgroup')
{
$sql_ary['group_time'] = $sql_ary['mod_time'] = TIMENOW;
$sql_args = DB()->build_array('INSERT', $sql_ary);
bb_die($message);
} elseif ($mode == 'newgroup') {
$sql_ary['group_time'] = $sql_ary['mod_time'] = TIMENOW;
$sql_args = DB()->build_array('INSERT', $sql_ary);
// Create new group
DB()->query("INSERT INTO ". BB_GROUPS ." $sql_args");
$new_group_id = DB()->sql_nextid();
// Create new group
DB()->query("INSERT INTO " . BB_GROUPS . " $sql_args");
$new_group_id = DB()->sql_nextid();
// Create user_group for group's moderator
add_user_into_group($new_group_id, $group_moderator);
// Create user_group for group's moderator
add_user_into_group($new_group_id, $group_moderator);
$message = $lang['ADDED_NEW_GROUP'] .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_GROUPSADMIN'], '<a href="admin_groups.php">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$message = $lang['ADDED_NEW_GROUP'] . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_GROUPSADMIN'], '<a href="admin_groups.php">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
else
{
bb_die($lang['NO_GROUP_ACTION']);
}
}
}
else
{
$template->assign_vars(array(
'TPL_GROUP_SELECT' => true,
bb_die($message);
} else {
bb_die($lang['NO_GROUP_ACTION']);
}
}
} else {
$template->assign_vars(array(
'TPL_GROUP_SELECT' => true,
'S_GROUP_ACTION' => "admin_groups.php",
'S_GROUP_SELECT' => stripslashes(get_select('groups')),
));
'S_GROUP_ACTION' => "admin_groups.php",
'S_GROUP_SELECT' => stripslashes(get_select('groups')),
));
}
print_page('admin_groups.tpl', 'admin');
print_page('admin_groups.tpl', 'admin');

View file

@ -1,60 +1,81 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['USERS']['ACTIONS_LOG'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['USERS']['ACTIONS_LOG'] = basename(__FILE__);
return;
}
require('./pagestart.php');
$datastore->enqueue(array(
'moderators',
'moderators',
));
$log_action->init();
$per_page = 50;
$row_class_1 = 'row1';
$row_class_2 = 'row2';
$def_days = 3;
$def_datetime = TIMENOW;
$max_forum_name_len = 40;
$per_page = 50;
$row_class_1 = 'row1';
$row_class_2 = 'row2';
$def_days = 3;
$def_datetime = TIMENOW;
$max_forum_name_len = 40;
$title_match_max_len = 60;
$poster_name_max_len = 25;
$select_max_height = 16;
$dt_format = 'Y-m-d'; // used in one-day filter
$select_max_height = 16;
$dt_format = 'Y-m-d'; // used in one-day filter
$url = basename(__FILE__);
// Key names
$type_key = 'type';
$forum_key = 'f';
$topic_key = 't';
$user_key = 'u';
$datetime_key = 'dt'; // value should be strtotime() time ("2006-06-25" etc.)
$daysback_key = 'db';
$sort_key = 'sort';
$type_key = 'type';
$forum_key = 'f';
$topic_key = 't';
$user_key = 'u';
$datetime_key = 'dt'; // value should be strtotime() time ("2006-06-25" etc.)
$daysback_key = 'db';
$sort_key = 'sort';
$title_match_key = 'tm';
// Key values
$all_types = 0; // =|
$all_users = 0; // |> only "0" is a valid value
$all_types = 0; // =|
$all_users = 0; // |> only "0" is a valid value
$all_forums = 0; // =|
$sort_asc = 'ASC';
$sort_desc = 'DESC';
$sort_asc = 'ASC';
$sort_desc = 'DESC';
// Defaults
$def_types = $all_types;
$def_users = $all_users;
$def_types = $all_types;
$def_users = $all_users;
$def_forums = $all_forums;
$def_sort = $sort_desc;
$def_sort = $sort_desc;
// Moderators data
if (!$mod = $datastore->get('moderators'))
{
$datastore->update('moderators');
$mod = $datastore->get('moderators');
if (!$mod = $datastore->get('moderators')) {
$datastore->update('moderators');
$mod = $datastore->get('moderators');
}
array_deep($mod['moderators'], 'html_entity_decode');
array_deep($mod['admins'], 'html_entity_decode');
@ -64,10 +85,9 @@ $users = array($lang['ACTS_LOG_ALL_ACTIONS'] => $all_users) + array_flip($mod['m
unset($mod);
// Forums data
if (!$forums = $datastore->get('cat_forums'))
{
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$f_data = $forums['f'];
@ -80,59 +100,52 @@ $start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0;
$type_selected = array($def_types);
$type_csv = '';
if ($var =& $_REQUEST[$type_key])
{
$type_selected = get_id_ary($var);
if ($var =& $_REQUEST[$type_key]) {
$type_selected = get_id_ary($var);
if (in_array($all_types, $type_selected))
{
$type_selected = array($all_types);
}
$type_csv = join(',', $type_selected);
$url = ($type_csv != $def_types) ? url_arg($url, $type_key, $type_csv) : $url;
if (in_array($all_types, $type_selected)) {
$type_selected = array($all_types);
}
$type_csv = join(',', $type_selected);
$url = ($type_csv != $def_types) ? url_arg($url, $type_key, $type_csv) : $url;
}
// User
$user_selected = array($def_users);
$user_csv = '';
if ($var =& $_REQUEST[$user_key])
{
$user_selected = get_id_ary($var);
if ($var =& $_REQUEST[$user_key]) {
$user_selected = get_id_ary($var);
if (in_array($all_users, $user_selected))
{
$user_selected = array($all_users);
}
$user_csv = join(',', $user_selected);
$url = ($user_csv != $def_users) ? url_arg($url, $user_key, $user_csv) : $url;
if (in_array($all_users, $user_selected)) {
$user_selected = array($all_users);
}
$user_csv = join(',', $user_selected);
$url = ($user_csv != $def_users) ? url_arg($url, $user_key, $user_csv) : $url;
}
// Forum
$forum_selected = array($def_forums);
$forum_csv = '';
if ($var =& $_REQUEST[$forum_key])
{
$forum_selected = get_id_ary($var);
if ($var =& $_REQUEST[$forum_key]) {
$forum_selected = get_id_ary($var);
if (in_array($all_forums, $forum_selected))
{
$forum_selected = array($all_forums);
}
$forum_csv = join(',', $forum_selected);
$url = ($forum_csv != $def_forums) ? url_arg($url, $forum_key, $forum_csv) : $url;
if (in_array($all_forums, $forum_selected)) {
$forum_selected = array($all_forums);
}
$forum_csv = join(',', $forum_selected);
$url = ($forum_csv != $def_forums) ? url_arg($url, $forum_key, $forum_csv) : $url;
}
// Topic
$topic_selected = null;
$topic_csv = '';
if ($var =& $_REQUEST[$topic_key])
{
$topic_selected = get_id_ary($var);
$topic_csv = join(',', $topic_selected);
$url = ($topic_csv) ? url_arg($url, $topic_key, $topic_csv) : $url;
if ($var =& $_REQUEST[$topic_key]) {
$topic_selected = get_id_ary($var);
$topic_csv = join(',', $topic_selected);
$url = ($topic_csv) ? url_arg($url, $topic_key, $topic_csv) : $url;
}
// Order
@ -141,48 +154,42 @@ $order_val = 'log_time';
// Sort
$sort_val = $def_sort;
if ($var =& $_REQUEST[$sort_key] AND $var != $def_sort)
{
$sort_val = ($var == $sort_asc) ? $sort_asc : $sort_desc;
$url = url_arg($url, $sort_key, $sort_val);
if ($var =& $_REQUEST[$sort_key] and $var != $def_sort) {
$sort_val = ($var == $sort_asc) ? $sort_asc : $sort_desc;
$url = url_arg($url, $sort_key, $sort_val);
}
// Time
$datetime_val = $def_datetime;
$daysback_val = $def_days;
if ($var =& $_REQUEST[$daysback_key] AND $var != $def_days)
{
$daysback_val = max(intval($var), 1);
$url = url_arg($url, $daysback_key, $daysback_val);
if ($var =& $_REQUEST[$daysback_key] and $var != $def_days) {
$daysback_val = max(intval($var), 1);
$url = url_arg($url, $daysback_key, $daysback_val);
}
if ($var =& $_REQUEST[$datetime_key] AND $var != $def_datetime)
{
$tz = TIMENOW + (3600 * $bb_cfg['board_timezone']);
if (($tmp_timestamp = strtotime($var, $tz)) > 0)
{
$datetime_val = $tmp_timestamp;
$url = url_arg($url, $datetime_key, date($dt_format, $datetime_val));
}
if ($var =& $_REQUEST[$datetime_key] and $var != $def_datetime) {
$tz = TIMENOW + (3600 * $bb_cfg['board_timezone']);
if (($tmp_timestamp = strtotime($var, $tz)) > 0) {
$datetime_val = $tmp_timestamp;
$url = url_arg($url, $datetime_key, date($dt_format, $datetime_val));
}
}
$time_end_val = 86400 + mktime(0, 0, 0, date('m', $datetime_val), date('d', $datetime_val), date('Y', $datetime_val));
$time_start_val = $time_end_val - 86400*$daysback_val;
$time_start_val = $time_end_val - 86400 * $daysback_val;
// First log time
$row = DB()->fetch_row("SELECT MIN(log_time) AS first_log_time FROM ". BB_LOG);
$first_log_time = (int) $row['first_log_time'];
$row = DB()->fetch_row("SELECT MIN(log_time) AS first_log_time FROM " . BB_LOG);
$first_log_time = (int)$row['first_log_time'];
// Title match
$title_match_val = $title_match_sql = '';
if ($var =& $_REQUEST[$title_match_key])
{
if ($tmp_title_match = substr(urldecode(trim($var)), 0, $title_match_max_len))
{
$title_match_sql = DB()->escape($tmp_title_match);
$url = url_arg($url, $title_match_key, urlencode($tmp_title_match));
}
if ($var =& $_REQUEST[$title_match_key]) {
if ($tmp_title_match = substr(urldecode(trim($var)), 0, $title_match_max_len)) {
$title_match_sql = DB()->escape($tmp_title_match);
$url = url_arg($url, $title_match_key, urlencode($tmp_title_match));
}
}
//
@ -190,32 +197,32 @@ if ($var =& $_REQUEST[$title_match_key])
//
$select = "SELECT *";
$from = "FROM ". BB_LOG;
$from = "FROM " . BB_LOG;
$where = "
WHERE log_time BETWEEN $time_start_val AND $time_end_val
";
$where .= ($type_csv) ? "
AND log_type_id IN($type_csv)
" : '';
" : '';
$where .= ($user_csv) ? "
AND log_user_id IN($user_csv)
" : '';
" : '';
$where .= ($forum_csv) ? "
AND log_forum_id IN($forum_csv)
" : '';
" : '';
$where .= ($topic_csv) ? "
AND log_topic_id IN($topic_csv)
" : '';
" : '';
$where .= ($title_match_sql) ? "
AND MATCH (log_topic_title) AGAINST ('$title_match_sql' IN BOOLEAN MODE)
" : '';
" : '';
$order = "ORDER BY $order_val";
$sort = $sort_val;
$limit = "LIMIT $start, ". ($per_page + 1);
$limit = "LIMIT $start, " . ($per_page + 1);
$sql = "
$select
@ -229,147 +236,132 @@ $sql = "
$log_rowset = DB()->fetch_rowset($sql);
$log_count = count($log_rowset);
if ($log_count == $per_page + 1)
{
$items_count = $start + ($per_page * 2);
$pages = '?';
array_pop($log_rowset);
}
else
{
$items_count = $start + $log_count;
$pages = (!$log_count) ? 1 : ceil($items_count / $per_page);
if ($log_count == $per_page + 1) {
$items_count = $start + ($per_page * 2);
$pages = '?';
array_pop($log_rowset);
} else {
$items_count = $start + $log_count;
$pages = (!$log_count) ? 1 : ceil($items_count / $per_page);
}
generate_pagination($url, $items_count, $per_page, $start);
$filter = array();
if ($log_rowset)
{
$log_type = $log_action->log_type;
$log_type_flip = array_flip($log_type);
if ($log_rowset) {
$log_type = $log_action->log_type;
$log_type_flip = array_flip($log_type);
foreach ($log_rowset as $row_num => $row)
{
$msg = '';
$forum_name = $forum_name_new = '';
$topic_title = $topic_title_new = '';
foreach ($log_rowset as $row_num => $row) {
$msg = '';
$forum_name = $forum_name_new = '';
$topic_title = $topic_title_new = '';
$topic_deleted = ($row['log_type_id'] == $log_type['mod_topic_delete']);
$topic_deleted = ($row['log_type_id'] == $log_type['mod_topic_delete']);
switch ($row['log_type_id'])
{
case $log_type['mod_topic_delete']:
case $log_type['mod_topic_move']:
case $log_type['mod_topic_lock']:
case $log_type['mod_topic_unlock']:
case $log_type['mod_post_delete']:
case $log_type['mod_topic_split']:
// topic_title
if (!empty($row['log_topic_title']))
{
$topic_title = $row['log_topic_title'];
}
// topic_title_new
if (!empty($row['log_topic_title_new']))
{
$topic_title_new = $row['log_topic_title_new'];
}
// forum_name
if ($fid =& $row['log_forum_id'])
{
$forum_name = ($fname =& $f_data[$fid]['forum_name']) ? $fname : 'id:'. $row['log_forum_id'];
}
// forum_name_new
if ($fid =& $row['log_forum_id_new'])
{
$forum_name_new = ($fname =& $f_data[$fid]['forum_name']) ? $fname : 'id:'. $row['log_forum_id'];
}
switch ($row['log_type_id']) {
case $log_type['mod_topic_delete']:
case $log_type['mod_topic_move']:
case $log_type['mod_topic_lock']:
case $log_type['mod_topic_unlock']:
case $log_type['mod_post_delete']:
case $log_type['mod_topic_split']:
// topic_title
if (!empty($row['log_topic_title'])) {
$topic_title = $row['log_topic_title'];
}
// topic_title_new
if (!empty($row['log_topic_title_new'])) {
$topic_title_new = $row['log_topic_title_new'];
}
// forum_name
if ($fid =& $row['log_forum_id']) {
$forum_name = ($fname =& $f_data[$fid]['forum_name']) ? $fname : 'id:' . $row['log_forum_id'];
}
// forum_name_new
if ($fid =& $row['log_forum_id_new']) {
$forum_name_new = ($fname =& $f_data[$fid]['forum_name']) ? $fname : 'id:' . $row['log_forum_id'];
}
break;
}
break;
}
$msg .= " $row[log_msg]";
$msg .= " $row[log_msg]";
$row_class = !($row_num & 1) ? $row_class_1 : $row_class_2;
$row_class = !($row_num & 1) ? $row_class_1 : $row_class_2;
$datetime_href_s = url_arg($url, $datetime_key, date($dt_format, $row['log_time']));
$datetime_href_s = url_arg($datetime_href_s, $daysback_key, 1);
$datetime_href_s = url_arg($url, $datetime_key, date($dt_format, $row['log_time']));
$datetime_href_s = url_arg($datetime_href_s, $daysback_key, 1);
$template->assign_block_vars('log', array(
'ACTION_DESC' => $lang['LOG_ACTION']['LOG_TYPE'][$log_type_flip[$row['log_type_id']]],
'ACTION_HREF_S' => url_arg($url, $type_key, $row['log_type_id']),
$template->assign_block_vars('log', array(
'ACTION_DESC' => $lang['LOG_ACTION']['LOG_TYPE'][$log_type_flip[$row['log_type_id']]],
'ACTION_HREF_S' => url_arg($url, $type_key, $row['log_type_id']),
'USER_ID' => $row['log_user_id'],
'USERNAME' => $row['log_username'],
'USER_HREF_S' => url_arg($url, $user_key, $row['log_user_id']),
'USER_IP' => decode_ip($row['log_user_ip']),
'USER_ID' => $row['log_user_id'],
'USERNAME' => $row['log_username'],
'USER_HREF_S' => url_arg($url, $user_key, $row['log_user_id']),
'USER_IP' => decode_ip($row['log_user_ip']),
'FORUM_ID' => $row['log_forum_id'],
'FORUM_HREF' => BB_ROOT . FORUM_URL . $row['log_forum_id'],
'FORUM_HREF_S' => url_arg($url, $forum_key, $row['log_forum_id']),
'FORUM_NAME' => htmlCHR($forum_name),
'FORUM_ID' => $row['log_forum_id'],
'FORUM_HREF' => BB_ROOT . FORUM_URL . $row['log_forum_id'],
'FORUM_HREF_S' => url_arg($url, $forum_key, $row['log_forum_id']),
'FORUM_NAME' => htmlCHR($forum_name),
'FORUM_ID_NEW' => $row['log_forum_id_new'],
'FORUM_HREF_NEW' => BB_ROOT . FORUM_URL . $row['log_forum_id_new'],
'FORUM_HREF_NEW_S' => url_arg($url, $forum_key, $row['log_forum_id_new']),
'FORUM_NAME_NEW' => htmlCHR($forum_name_new),
'FORUM_ID_NEW' => $row['log_forum_id_new'],
'FORUM_HREF_NEW' => BB_ROOT . FORUM_URL . $row['log_forum_id_new'],
'FORUM_HREF_NEW_S' => url_arg($url, $forum_key, $row['log_forum_id_new']),
'FORUM_NAME_NEW' => htmlCHR($forum_name_new),
'TOPIC_ID' => $row['log_topic_id'],
'TOPIC_HREF' => (!$topic_deleted) ? BB_ROOT . TOPIC_URL . $row['log_topic_id'] : '',
'TOPIC_HREF_S' => url_arg($url, $topic_key, $row['log_topic_id']),
'TOPIC_TITLE' => $topic_title,
'TOPIC_ID' => $row['log_topic_id'],
'TOPIC_HREF' => (!$topic_deleted) ? BB_ROOT . TOPIC_URL . $row['log_topic_id'] : '',
'TOPIC_HREF_S' => url_arg($url, $topic_key, $row['log_topic_id']),
'TOPIC_TITLE' => $topic_title,
'TOPIC_ID_NEW' => $row['log_topic_id_new'],
'TOPIC_HREF_NEW' => BB_ROOT . TOPIC_URL . $row['log_topic_id_new'],
'TOPIC_HREF_NEW_S' => url_arg($url, $topic_key, $row['log_topic_id_new']),
'TOPIC_TITLE_NEW' => $topic_title_new,
'TOPIC_ID_NEW' => $row['log_topic_id_new'],
'TOPIC_HREF_NEW' => BB_ROOT . TOPIC_URL . $row['log_topic_id_new'],
'TOPIC_HREF_NEW_S' => url_arg($url, $topic_key, $row['log_topic_id_new']),
'TOPIC_TITLE_NEW' => $topic_title_new,
'DATE' => bb_date($row['log_time'], 'j-M'),
'TIME' => bb_date($row['log_time'], 'H:i'),
'DATETIME_HREF_S' => $datetime_href_s,
'MSG' => $msg,
'ROW_CLASS' => $row_class,
'DATE' => bb_date($row['log_time'], 'j-M'),
'TIME' => bb_date($row['log_time'], 'H:i'),
'DATETIME_HREF_S' => $datetime_href_s,
'MSG' => $msg,
'ROW_CLASS' => $row_class,
));
));
// Topics
if ($topic_csv && empty($filter['topics'][$row['log_topic_title']]))
{
$template->assign_block_vars('topics', array(
'TOPIC_TITLE' => $row['log_topic_title'],
));
$filter['topics'][$row['log_topic_title']] = true;
}
// Forums
if ($forum_csv && empty($filter['forums'][$forum_name]))
{
$template->assign_block_vars('forums', array(
'FORUM_NAME' => htmlCHR($forum_name),
));
$filter['forums'][$forum_name] = true;
}
// Users
if ($user_csv && empty($filter['users'][$row['log_username']]))
{
$template->assign_block_vars('users', array(
'USERNAME' => $row['log_username'],
));
$filter['users'][$row['log_username']] = true;
}
}
// Topics
if ($topic_csv && empty($filter['topics'][$row['log_topic_title']])) {
$template->assign_block_vars('topics', array(
'TOPIC_TITLE' => $row['log_topic_title'],
));
$filter['topics'][$row['log_topic_title']] = true;
}
// Forums
if ($forum_csv && empty($filter['forums'][$forum_name])) {
$template->assign_block_vars('forums', array(
'FORUM_NAME' => htmlCHR($forum_name),
));
$filter['forums'][$forum_name] = true;
}
// Users
if ($user_csv && empty($filter['users'][$row['log_username']])) {
$template->assign_block_vars('users', array(
'USERNAME' => $row['log_username'],
));
$filter['users'][$row['log_username']] = true;
}
}
$template->assign_vars(array(
'FILTERS' => ($topic_csv || $forum_csv || $user_csv),
'FILTER_TOPICS' => !empty($filter['topics']),
'FILTER_FORUMS' => !empty($filter['forums']),
'FILTER_USERS' => !empty($filter['users']),
));
}
else
{
$template->assign_block_vars('log_not_found', array());
$template->assign_vars(array(
'FILTERS' => ($topic_csv || $forum_csv || $user_csv),
'FILTER_TOPICS' => !empty($filter['topics']),
'FILTER_FORUMS' => !empty($filter['forums']),
'FILTER_USERS' => !empty($filter['users']),
));
} else {
$template->assign_block_vars('log_not_found', array());
}
//
@ -378,36 +370,36 @@ else
$log_type_select = array($lang['ACTS_LOG_ALL_ACTIONS'] => $all_types) + $log_action->log_type_select;
// Order select
$order_options = '<option value="">&nbsp;'.$lang['ACTS_LOG_TIME'].'&nbsp;</option>';
$order_options = '<option value="">&nbsp;' . $lang['ACTS_LOG_TIME'] . '&nbsp;</option>';
$template->assign_vars(array(
'LOG_COLSPAN' => 4,
'LOG_COLSPAN' => 4,
'DATETIME_NAME' => $datetime_key,
'DATETIME_VAL' => date('Y-m-d', $datetime_val),
'DAYSBACK_NAME' => $daysback_key,
'DAYSBACK_VAL' => $daysback_val,
'FIRST_LOG_TIME' => ($first_log_time) ? date('Y-m-d', $first_log_time) : $lang['ACC_NONE'],
'DATETIME_NAME' => $datetime_key,
'DATETIME_VAL' => date('Y-m-d', $datetime_val),
'DAYSBACK_NAME' => $daysback_key,
'DAYSBACK_VAL' => $daysback_val,
'FIRST_LOG_TIME' => ($first_log_time) ? date('Y-m-d', $first_log_time) : $lang['ACC_NONE'],
'TITLE_MATCH_MAX' => $title_match_max_len,
'TITLE_MATCH_NAME' => $title_match_key,
'TITLE_MATCH_VAL' => $title_match_val,
'TITLE_MATCH_MAX' => $title_match_max_len,
'TITLE_MATCH_NAME' => $title_match_key,
'TITLE_MATCH_VAL' => $title_match_val,
'ORDER_NAME' => '',
'ORDER_OPTIONS' => $order_options,
'ORDER_NAME' => '',
'ORDER_OPTIONS' => $order_options,
'SORT_NAME' => $sort_key,
'SORT_ASC' => $sort_asc,
'SORT_DESC' => $sort_desc,
'SORT_ASC_CHECKED' => ($sort_val == $sort_asc) ? HTML_CHECKED : '',
'SORT_DESC_CHECKED' => ($sort_val == $sort_desc) ? HTML_CHECKED : '',
'SORT_NAME' => $sort_key,
'SORT_ASC' => $sort_asc,
'SORT_DESC' => $sort_desc,
'SORT_ASC_CHECKED' => ($sort_val == $sort_asc) ? HTML_CHECKED : '',
'SORT_DESC_CHECKED' => ($sort_val == $sort_desc) ? HTML_CHECKED : '',
'SEL_FORUM' => get_forum_select('admin', "{$forum_key}[]", $forum_selected, $max_forum_name_len, $select_max_height, '', $all_forums),
'SEL_LOG_TYPE' => build_select("{$type_key}[]", $log_type_select, $type_selected, 60, $select_max_height),
'SEL_USERS' => build_select("{$user_key}[]", $users, $user_selected, 16, $select_max_height),
'SEL_FORUM' => get_forum_select('admin', "{$forum_key}[]", $forum_selected, $max_forum_name_len, $select_max_height, '', $all_forums),
'SEL_LOG_TYPE' => build_select("{$type_key}[]", $log_type_select, $type_selected, 60, $select_max_height),
'SEL_USERS' => build_select("{$user_key}[]", $users, $user_selected, 16, $select_max_height),
'S_LOG_ACTION' => "admin_log.php",
'TOPIC_CSV' => $topic_csv,
'S_LOG_ACTION' => "admin_log.php",
'TOPIC_CSV' => $topic_csv,
));
print_page('admin_log.tpl', 'admin');
print_page('admin_log.tpl', 'admin');

View file

@ -1,102 +1,122 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['MODS']['MASS_EMAIL'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['MODS']['MASS_EMAIL'] = basename(__FILE__);
return;
}
require('./pagestart.php');
@set_time_limit(1200);
$subject = (string) trim(request_var('subject', ''));
$message = (string) request_var('message', '');
$group_id = (int) request_var(POST_GROUPS_URL, 0);
$subject = (string)trim(request_var('subject', ''));
$message = (string)request_var('message', '');
$group_id = (int)request_var(POST_GROUPS_URL, 0);
$errors = $user_id_sql = array();
if (isset($_POST['submit']))
{
if (!$subject) $errors[] = $lang['EMPTY_SUBJECT'];
if (!$message) $errors[] = $lang['EMPTY_MESSAGE'];
if (!$group_id) $errors[] = $lang['GROUP_NOT_EXIST'];
if (isset($_POST['submit'])) {
if (!$subject) {
$errors[] = $lang['EMPTY_SUBJECT'];
}
if (!$message) {
$errors[] = $lang['EMPTY_MESSAGE'];
}
if (!$group_id) {
$errors[] = $lang['GROUP_NOT_EXIST'];
}
if (!$errors)
{
$sql = DB()->fetch_rowset("SELECT ban_userid FROM ". BB_BANLIST ." WHERE ban_userid != 0");
if (!$errors) {
$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
foreach ($sql as $row)
{
$user_id_sql[] = ','. $row['ban_userid'];
}
$user_id_sql = join('', $user_id_sql);
foreach ($sql as $row) {
$user_id_sql[] = ',' . $row['ban_userid'];
}
$user_id_sql = join('', $user_id_sql);
if ($group_id != -1)
{
$user_list = DB()->fetch_rowset("
if ($group_id != -1) {
$user_list = DB()->fetch_rowset("
SELECT u.username, u.user_email, u.user_lang
FROM ". BB_USERS ." u, ". BB_USER_GROUP ." ug
FROM " . BB_USERS . " u, " . BB_USER_GROUP . " ug
WHERE ug.group_id = $group_id
AND ug.user_pending = 0
AND u.user_id = ug.user_id
AND u.user_active = 1
AND u.user_id NOT IN(". EXCLUDED_USERS_CSV . $user_id_sql .")
AND u.user_id NOT IN(" . EXCLUDED_USERS_CSV . $user_id_sql . ")
");
}
else
{
$user_list = DB()->fetch_rowset("
} else {
$user_list = DB()->fetch_rowset("
SELECT username, user_email, user_lang
FROM ". BB_USERS ."
FROM " . BB_USERS . "
WHERE user_active = 1
AND user_id NOT IN(". EXCLUDED_USERS_CSV . $user_id_sql .")
AND user_id NOT IN(" . EXCLUDED_USERS_CSV . $user_id_sql . ")
");
}
}
require(CLASS_DIR .'emailer.php');
require(CLASS_DIR . 'emailer.php');
foreach ($user_list as $i => $row)
{
$emailer = new emailer($bb_cfg['smtp_delivery']);
foreach ($user_list as $i => $row) {
$emailer = new emailer($bb_cfg['smtp_delivery']);
$emailer->from($bb_cfg['sitename'] ." <{$bb_cfg['board_email']}>");
$emailer->email_address($row['username'] ." <{$row['user_email']}>");
$emailer->use_template('admin_send_email');
$emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>");
$emailer->email_address($row['username'] . " <{$row['user_email']}>");
$emailer->use_template('admin_send_email');
$emailer->assign_vars(array(
'SUBJECT' => html_entity_decode($subject),
'MESSAGE' => html_entity_decode($message),
));
$emailer->assign_vars(array(
'SUBJECT' => html_entity_decode($subject),
'MESSAGE' => html_entity_decode($message),
));
$emailer->send();
$emailer->reset();
}
}
$emailer->send();
$emailer->reset();
}
}
}
//
// Generate page
//
$sql = "SELECT group_id, group_name
FROM ". BB_GROUPS ."
FROM " . BB_GROUPS . "
WHERE group_single_user = 0
ORDER BY group_name
";
$groups = array('-- '. $lang['ALL_USERS'] .' --' => -1);
foreach (DB()->fetch_rowset($sql) as $row)
{
$groups[$row['group_name']] = $row['group_id'];
$groups = array('-- ' . $lang['ALL_USERS'] . ' --' => -1);
foreach (DB()->fetch_rowset($sql) as $row) {
$groups[$row['group_name']] = $row['group_id'];
}
$template->assign_vars(array(
'MESSAGE' => $message,
'SUBJECT' => $subject,
'MESSAGE' => $message,
'SUBJECT' => $subject,
'ERROR_MESSAGE' => ($errors) ? join('<br />', array_unique($errors)) : '',
'ERROR_MESSAGE' => ($errors) ? join('<br />', array_unique($errors)) : '',
'S_USER_ACTION' => 'admin_mass_email.php',
'S_GROUP_SELECT' => build_select(POST_GROUPS_URL, $groups),
'S_USER_ACTION' => 'admin_mass_email.php',
'S_GROUP_SELECT' => build_select(POST_GROUPS_URL, $groups),
));
print_page('admin_mass_email.tpl', 'admin');
print_page('admin_mass_email.tpl', 'admin');

View file

@ -1,10 +1,32 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['GENERAL']['PHP_INFO'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['GENERAL']['PHP_INFO'] = basename(__FILE__);
return;
}
require('./pagestart.php');
phpinfo();
phpinfo();

View file

@ -1,254 +1,232 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['USERS']['RANKS'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['USERS']['RANKS'] = basename(__FILE__);
return;
}
require('./pagestart.php');
$_POST['special_rank'] = 1;
$_POST['min_posts'] = -1;
if (isset($_GET['mode']) || isset($_POST['mode']))
{
$mode = isset($_GET['mode']) ? $_GET['mode'] : $_POST['mode'];
}
else
{
//
// These could be entered via a form button
//
if (isset($_POST['add']))
{
$mode = 'add';
}
elseif (isset($_POST['save']))
{
$mode = 'save';
}
else
{
$mode = '';
}
if (isset($_GET['mode']) || isset($_POST['mode'])) {
$mode = isset($_GET['mode']) ? $_GET['mode'] : $_POST['mode'];
} else {
//
// These could be entered via a form button
//
if (isset($_POST['add'])) {
$mode = 'add';
} elseif (isset($_POST['save'])) {
$mode = 'save';
} else {
$mode = '';
}
}
if ($mode != '')
{
if ($mode == 'edit' || $mode == 'add')
{
//
// They want to add a new rank, show the form.
//
$rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
if ($mode != '') {
if ($mode == 'edit' || $mode == 'add') {
//
// They want to add a new rank, show the form.
//
$rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$s_hidden_fields = '';
$s_hidden_fields = '';
if ($mode == 'edit')
{
if (empty($rank_id))
{
bb_die($lang['MUST_SELECT_RANK']);
}
if ($mode == 'edit') {
if (empty($rank_id)) {
bb_die($lang['MUST_SELECT_RANK']);
}
$sql = "SELECT * FROM " . BB_RANKS . " WHERE rank_id = $rank_id";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not obtain ranks data #1');
}
$sql = "SELECT * FROM " . BB_RANKS . " WHERE rank_id = $rank_id";
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain ranks data #1');
}
$rank_info = DB()->sql_fetchrow($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="'. $rank_id .'" />';
}
else
{
$rank_info['rank_special'] = 0;
}
$rank_info = DB()->sql_fetchrow($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $rank_id . '" />';
} else {
$rank_info['rank_special'] = 0;
}
$s_hidden_fields .= '<input type="hidden" name="mode" value="save" />';
$s_hidden_fields .= '<input type="hidden" name="mode" value="save" />';
$rank_is_special = !empty($rank_info['rank_special']) ? HTML_CHECKED : '';
$rank_is_not_special = empty($rank_info['rank_special']) ? HTML_CHECKED : '';
$rank_is_special = !empty($rank_info['rank_special']) ? HTML_CHECKED : '';
$rank_is_not_special = empty($rank_info['rank_special']) ? HTML_CHECKED : '';
$template->assign_vars(array(
'TPL_RANKS_EDIT' => true,
$template->assign_vars(array(
'TPL_RANKS_EDIT' => true,
'RANK' => !empty($rank_info['rank_title']) ? $rank_info['rank_title'] : '',
'SPECIAL_RANK' => $rank_is_special,
'NOT_SPECIAL_RANK' => $rank_is_not_special,
'MINIMUM' => ($rank_is_special) ? '' : @$rank_info['rank_min'],
'IMAGE' => !empty($rank_info['rank_image']) ? $rank_info['rank_image'] : 'styles/images/ranks/rank_image.png',
'STYLE' => !empty($rank_info['rank_style']) ? $rank_info['rank_style'] : '',
'IMAGE_DISPLAY' => !empty($rank_info['rank_image']) ? '<img src="../'. $rank_info['rank_image'] .'" />' : '',
'RANK' => !empty($rank_info['rank_title']) ? $rank_info['rank_title'] : '',
'SPECIAL_RANK' => $rank_is_special,
'NOT_SPECIAL_RANK' => $rank_is_not_special,
'MINIMUM' => ($rank_is_special) ? '' : @$rank_info['rank_min'],
'IMAGE' => !empty($rank_info['rank_image']) ? $rank_info['rank_image'] : 'styles/images/ranks/rank_image.png',
'STYLE' => !empty($rank_info['rank_style']) ? $rank_info['rank_style'] : '',
'IMAGE_DISPLAY' => !empty($rank_info['rank_image']) ? '<img src="../' . $rank_info['rank_image'] . '" />' : '',
'S_RANK_ACTION' => "admin_ranks.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
elseif ($mode == 'save')
{
//
// Ok, they sent us our info, let's update it.
//
'S_RANK_ACTION' => "admin_ranks.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
} elseif ($mode == 'save') {
//
// Ok, they sent us our info, let's update it.
//
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
$rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : '';
$rank_style = (isset($_POST['style'])) ? trim($_POST['style']) : '';
$special_rank = ($_POST['special_rank'] == 1) ? TRUE : 0;
$min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1;
$rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : '';
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
$rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : '';
$rank_style = (isset($_POST['style'])) ? trim($_POST['style']) : '';
$special_rank = ($_POST['special_rank'] == 1) ? true : 0;
$min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1;
$rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : '';
if ($rank_title == '')
{
bb_die($lang['MUST_SELECT_RANK']);
}
if ($rank_title == '') {
bb_die($lang['MUST_SELECT_RANK']);
}
if ($special_rank == 1)
{
$max_posts = -1;
$min_posts = -1;
}
if ($special_rank == 1) {
$max_posts = -1;
$min_posts = -1;
}
//
// The rank image has to be a jpg, gif or png
//
if ($rank_image != '')
{
if (!preg_match('/(\.gif|\.png|\.jpg)$/is', $rank_image))
{
$rank_image = '';
}
}
//
// The rank image has to be a jpg, gif or png
//
if ($rank_image != '') {
if (!preg_match('/(\.gif|\.png|\.jpg)$/is', $rank_image)) {
$rank_image = '';
}
}
if ($rank_id)
{
if (!$special_rank)
{
$sql = "UPDATE " . BB_USERS . " SET user_rank = 0 WHERE user_rank = $rank_id";
if (!$result = DB()->sql_query($sql))
{
bb_die($lang['NO_UPDATE_RANKS']);
}
}
$sql = "UPDATE " . BB_RANKS . "
SET rank_title = '". DB()->escape($rank_title) ."',
if ($rank_id) {
if (!$special_rank) {
$sql = "UPDATE " . BB_USERS . " SET user_rank = 0 WHERE user_rank = $rank_id";
if (!$result = DB()->sql_query($sql)) {
bb_die($lang['NO_UPDATE_RANKS']);
}
}
$sql = "UPDATE " . BB_RANKS . "
SET rank_title = '" . DB()->escape($rank_title) . "',
rank_special = $special_rank,
rank_min = $min_posts,
rank_image = '". DB()->escape($rank_image) . "',
rank_style = '". DB()->escape($rank_style) ."'
rank_image = '" . DB()->escape($rank_image) . "',
rank_style = '" . DB()->escape($rank_style) . "'
WHERE rank_id = $rank_id";
$message = $lang['RANK_UPDATED'];
}
else
{
$sql = "INSERT INTO " . BB_RANKS . " (rank_title, rank_special, rank_min, rank_image, rank_style)
VALUES ('". DB()->escape($rank_title) ."', $special_rank, $min_posts, '". DB()->escape($rank_image) ."', '". DB()->escape($rank_style) ."')";
$message = $lang['RANK_UPDATED'];
} else {
$sql = "INSERT INTO " . BB_RANKS . " (rank_title, rank_special, rank_min, rank_image, rank_style)
VALUES ('" . DB()->escape($rank_title) . "', $special_rank, $min_posts, '" . DB()->escape($rank_image) . "', '" . DB()->escape($rank_style) . "')";
$message = $lang['RANK_ADDED'];
}
$message = $lang['RANK_ADDED'];
}
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not update / insert into ranks table');
}
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not update / insert into ranks table');
}
$message .= '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$message .= '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$datastore->update('ranks');
$datastore->update('ranks');
bb_die($message);
}
elseif ($mode == 'delete')
{
//
// Ok, they want to delete their rank
//
bb_die($message);
} elseif ($mode == 'delete') {
//
// Ok, they want to delete their rank
//
if (isset($_POST['id']) || isset($_GET['id']))
{
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']);
}
else
{
$rank_id = 0;
}
if (isset($_POST['id']) || isset($_GET['id'])) {
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']);
} else {
$rank_id = 0;
}
if ($rank_id)
{
$sql = "DELETE FROM " . BB_RANKS . " WHERE rank_id = $rank_id";
if ($rank_id) {
$sql = "DELETE FROM " . BB_RANKS . " WHERE rank_id = $rank_id";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not delete rank data');
}
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not delete rank data');
}
$sql = "UPDATE " . BB_USERS . " SET user_rank = 0 WHERE user_rank = $rank_id";
if (!$result = DB()->sql_query($sql))
{
bb_die($lang['NO_UPDATE_RANKS']);
}
$sql = "UPDATE " . BB_USERS . " SET user_rank = 0 WHERE user_rank = $rank_id";
if (!$result = DB()->sql_query($sql)) {
bb_die($lang['NO_UPDATE_RANKS']);
}
$datastore->update('ranks');
$datastore->update('ranks');
bb_die($lang['RANK_REMOVED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
else
{
bb_die($lang['MUST_SELECT_RANK']);
}
}
else
{
bb_die('Invalid mode');
}
}
else
{
//
// Show the default page
//
$sql = "SELECT * FROM " . BB_RANKS . " ORDER BY rank_min, rank_title";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not obtain ranks data #2');
}
$rank_count = DB()->num_rows($result);
$rank_rows = DB()->sql_fetchrowset($result);
bb_die($lang['RANK_REMOVED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} else {
bb_die($lang['MUST_SELECT_RANK']);
}
} else {
bb_die('Invalid mode');
}
} else {
//
// Show the default page
//
$sql = "SELECT * FROM " . BB_RANKS . " ORDER BY rank_min, rank_title";
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain ranks data #2');
}
$rank_count = DB()->num_rows($result);
$rank_rows = DB()->sql_fetchrowset($result);
$template->assign_vars(array(
'TPL_RANKS_LIST' => true,
'S_RANKS_ACTION' => "admin_ranks.php",
));
$template->assign_vars(array(
'TPL_RANKS_LIST' => true,
'S_RANKS_ACTION' => "admin_ranks.php",
));
for ($i = 0; $i < $rank_count; $i++)
{
$rank = $rank_rows[$i]['rank_title'];
$special_rank = $rank_rows[$i]['rank_special'];
$rank_id = $rank_rows[$i]['rank_id'];
$rank_min = $rank_rows[$i]['rank_min'];
for ($i = 0; $i < $rank_count; $i++) {
$rank = $rank_rows[$i]['rank_title'];
$special_rank = $rank_rows[$i]['rank_special'];
$rank_id = $rank_rows[$i]['rank_id'];
$rank_min = $rank_rows[$i]['rank_min'];
if ($special_rank == 1)
{
$rank_min = $rank_max = '-';
}
if ($special_rank == 1) {
$rank_min = $rank_max = '-';
}
$row_class = !($i % 2) ? 'row1' : 'row2';
$row_class = !($i % 2) ? 'row1' : 'row2';
$rank_is_special = ($special_rank) ? $lang['YES'] : $lang['NO'];
$rank_is_special = ($special_rank) ? $lang['YES'] : $lang['NO'];
$template->assign_block_vars('ranks', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'STYLE' => $rank_rows[$i]['rank_style'],
'IMAGE_DISPLAY' => ($rank_rows[$i]['rank_image']) ? '<img src="../'. $rank_rows[$i]['rank_image'] .'" />' : '',
'SPECIAL_RANK' => $rank_is_special,
'RANK_MIN' => $rank_min,
$template->assign_block_vars('ranks', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'STYLE' => $rank_rows[$i]['rank_style'],
'IMAGE_DISPLAY' => ($rank_rows[$i]['rank_image']) ? '<img src="../' . $rank_rows[$i]['rank_image'] . '" />' : '',
'SPECIAL_RANK' => $rank_is_special,
'RANK_MIN' => $rank_min,
'U_RANK_EDIT' => "admin_ranks.php?mode=edit&amp;id=$rank_id",
'U_RANK_DELETE' => "admin_ranks.php?mode=delete&amp;id=$rank_id",
));
}
'U_RANK_EDIT' => "admin_ranks.php?mode=edit&amp;id=$rank_id",
'U_RANK_DELETE' => "admin_ranks.php?mode=delete&amp;id=$rank_id",
));
}
}
print_page('admin_ranks.tpl', 'admin');
print_page('admin_ranks.tpl', 'admin');

File diff suppressed because it is too large Load diff

View file

@ -1,52 +1,67 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['MODS']['SITEMAP'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['MODS']['SITEMAP'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require(INC_DIR .'functions_selects.php');
require(INC_DIR . 'functions_selects.php');
$sql = "SELECT * FROM " . BB_CONFIG;
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not query config information in admin_sitemap');
}
else
{
$new_params = array();
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query config information in admin_sitemap');
} else {
$new_params = array();
while ($row = DB()->sql_fetchrow($result))
{
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name];
while ($row = DB()->sql_fetchrow($result)) {
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name];
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name])
{
$new_params[$config_name] = $new[$config_name];
}
}
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
$new_params[$config_name] = $new[$config_name];
}
}
if (isset($_POST['submit']))
{
if (!empty($new_params))
{
bb_update_config($new_params);
}
}
if (isset($_POST['submit'])) {
if (!empty($new_params)) {
bb_update_config($new_params);
}
}
}
$s_mess = $lang['SITEMAP_CREATED'].': <b>'.bb_date($new['sitemap_time'], $bb_cfg['post_date_format']).'</b> '.$lang['SITEMAP_AVAILABLE'].': <a href="'.make_url('sitemap.xml').'" target="_blank">'.make_url('sitemap.xml').'</a>';
$message = (@file_exists(BB_ROOT. "/internal_data/sitemap/sitemap.xml")) ? $s_mess : $lang['SITEMAP_NOT_CREATED'];
$s_mess = $lang['SITEMAP_CREATED'] . ': <b>' . bb_date($new['sitemap_time'], $bb_cfg['post_date_format']) . '</b> ' . $lang['SITEMAP_AVAILABLE'] . ': <a href="' . make_url('sitemap.xml') . '" target="_blank">' . make_url('sitemap.xml') . '</a>';
$message = (@file_exists(BB_ROOT . "/internal_data/sitemap/sitemap.xml")) ? $s_mess : $lang['SITEMAP_NOT_CREATED'];
$template->assign_vars(array(
'STATIC_SITEMAP' => $new['static_sitemap'],
'MESSAGE' => $message,
'STATIC_SITEMAP' => $new['static_sitemap'],
'MESSAGE' => $message,
));
print_page('admin_sitemap.tpl', 'admin');
print_page('admin_sitemap.tpl', 'admin');

View file

@ -1,370 +1,336 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['GENERAL']['SMILIES'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['GENERAL']['SMILIES'] = basename(__FILE__);
return;
}
require('./pagestart.php');
// Check to see what mode we should operate in
if (isset($_POST['mode']) || isset($_GET['mode']))
{
$mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode'];
$mode = htmlspecialchars($mode);
}
else
{
$mode = '';
if (isset($_POST['mode']) || isset($_GET['mode'])) {
$mode = (isset($_POST['mode'])) ? $_POST['mode'] : $_GET['mode'];
$mode = htmlspecialchars($mode);
} else {
$mode = '';
}
$delimeter = '=+:';
$delimeter = '=+:';
// Read a listing of uploaded smilies for use in the add or edit smliey code
$dir = @opendir(BB_ROOT . $bb_cfg['smilies_path']);
while ($file = @readdir($dir))
{
if (!@is_dir(bb_realpath(BB_ROOT . $bb_cfg['smilies_path'] . '/' . $file)))
{
$img_size = @getimagesize(BB_ROOT . $bb_cfg['smilies_path'] . '/' . $file);
while ($file = @readdir($dir)) {
if (!@is_dir(bb_realpath(BB_ROOT . $bb_cfg['smilies_path'] . '/' . $file))) {
$img_size = @getimagesize(BB_ROOT . $bb_cfg['smilies_path'] . '/' . $file);
if ($img_size[0] && $img_size[1])
{
$smiley_images[] = $file;
}
else if (preg_match('/.pak$/i', $file))
{
$smiley_paks[] = $file;
}
}
if ($img_size[0] && $img_size[1]) {
$smiley_images[] = $file;
} elseif (preg_match('/.pak$/i', $file)) {
$smiley_paks[] = $file;
}
}
}
@closedir($dir);
// Select main mode
if (isset($_GET['import_pack']) || isset($_POST['import_pack']))
{
$smile_pak = (string) request_var('smile_pak', '');
$clear_current = (int) request_var('clear_current', '');
$replace_existing = (int) request_var('replace', '');
if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
$smile_pak = (string)request_var('smile_pak', '');
$clear_current = (int)request_var('clear_current', '');
$replace_existing = (int)request_var('replace', '');
if (!empty($smile_pak))
{
// The user has already selected a smile_pak file.. Import it
if (!empty($clear_current))
{
$sql = "DELETE FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not delete current smilies');
}
$datastore->update('smile_replacements');
}
else
{
$sql = "SELECT code FROM ". BB_SMILIES;
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not get current smilies');
}
if (!empty($smile_pak)) {
// The user has already selected a smile_pak file.. Import it
if (!empty($clear_current)) {
$sql = "DELETE FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not delete current smilies');
}
$datastore->update('smile_replacements');
} else {
$sql = "SELECT code FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get current smilies');
}
$cur_smilies = DB()->sql_fetchrowset($result);
$cur_smilies = DB()->sql_fetchrowset($result);
for ($i = 0; $i < count($cur_smilies); $i++)
{
$k = $cur_smilies[$i]['code'];
$smiles[$k] = 1;
}
}
for ($i = 0; $i < count($cur_smilies); $i++) {
$k = $cur_smilies[$i]['code'];
$smiles[$k] = 1;
}
}
$fcontents = @file(BB_ROOT . $bb_cfg['smilies_path'] . '/'. $smile_pak);
$fcontents = @file(BB_ROOT . $bb_cfg['smilies_path'] . '/' . $smile_pak);
if (empty($fcontents))
{
bb_die('Could not read smiley pak file');
}
if (empty($fcontents)) {
bb_die('Could not read smiley pak file');
}
for ($i = 0; $i < count($fcontents); $i++)
{
$smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));
for ($i = 0; $i < count($fcontents); $i++) {
$smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));
for ($j = 2; $j < count($smile_data); $j++)
{
// Replace > and < with the proper html_entities for matching
$smile_data[$j] = str_replace('<', '&lt;', $smile_data[$j]);
$smile_data[$j] = str_replace('>', '&gt;', $smile_data[$j]);
$k = $smile_data[$j];
for ($j = 2; $j < count($smile_data); $j++) {
// Replace > and < with the proper html_entities for matching
$smile_data[$j] = str_replace('<', '&lt;', $smile_data[$j]);
$smile_data[$j] = str_replace('>', '&gt;', $smile_data[$j]);
$k = $smile_data[$j];
if (isset($smiles[$k]))
{
if( !empty($replace_existing) )
{
$sql = "UPDATE " . BB_SMILIES . "
if (isset($smiles[$k])) {
if (!empty($replace_existing)) {
$sql = "UPDATE " . BB_SMILIES . "
SET smile_url = '" . DB()->escape($smile_data[0]) . "', emoticon = '" . DB()->escape($smile_data[1]) . "'
WHERE code = '" . DB()->escape($smile_data[$j]) . "'";
}
else
{
$sql = '';
}
}
else
{
$sql = "INSERT INTO " . BB_SMILIES . " (code, smile_url, emoticon)
} else {
$sql = '';
}
} else {
$sql = "INSERT INTO " . BB_SMILIES . " (code, smile_url, emoticon)
VALUES('" . DB()->escape($smile_data[$j]) . "', '" . DB()->escape($smile_data[0]) . "', '" . DB()->escape($smile_data[1]) . "')";
}
}
if ($sql != '')
{
$result = DB()->sql_query($sql);
if (!$result)
{
bb_die('Could not update smilies #1');
}
$datastore->update('smile_replacements');
}
}
}
if ($sql != '') {
$result = DB()->sql_query($sql);
if (!$result) {
bb_die('Could not update smilies #1');
}
$datastore->update('smile_replacements');
}
}
}
bb_die($lang['SMILEY_IMPORT_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
else
{
// Display the script to get the smile_pak cfg file
$smile_paks_select = '<select name="smile_pak"><option value="">' . $lang['SELECT_PAK'] . '</option>';
while (list($key, $value) = @each($smiley_paks))
{
if (!empty($value))
{
$smile_paks_select .= '<option>' . $value . '</option>';
}
}
$smile_paks_select .= '</select>';
bb_die($lang['SMILEY_IMPORT_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} else {
// Display the script to get the smile_pak cfg file
$smile_paks_select = '<select name="smile_pak"><option value="">' . $lang['SELECT_PAK'] . '</option>';
while (list($key, $value) = @each($smiley_paks)) {
if (!empty($value)) {
$smile_paks_select .= '<option>' . $value . '</option>';
}
}
$smile_paks_select .= '</select>';
$hidden_vars = '<input type="hidden" name="mode" value="import">';
$hidden_vars = '<input type="hidden" name="mode" value="import">';
$template->assign_vars(array(
'TPL_SMILE_IMPORT' => true,
$template->assign_vars(array(
'TPL_SMILE_IMPORT' => true,
'S_SMILEY_ACTION' => 'admin_smilies.php',
'S_SMILE_SELECT' => $smile_paks_select,
'S_HIDDEN_FIELDS' => $hidden_vars,
));
}
}
else if (isset($_POST['export_pack']) || isset($_GET['export_pack']))
{
$export_pack = (string) request_var('export_pack', '');
'S_SMILEY_ACTION' => 'admin_smilies.php',
'S_SMILE_SELECT' => $smile_paks_select,
'S_HIDDEN_FIELDS' => $hidden_vars,
));
}
} elseif (isset($_POST['export_pack']) || isset($_GET['export_pack'])) {
$export_pack = (string)request_var('export_pack', '');
if ($export_pack == 'send')
{
$sql = "SELECT * FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not get smiley list');
}
if ($export_pack == 'send') {
$sql = "SELECT * FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get smiley list');
}
$resultset = DB()->sql_fetchrowset($result);
$resultset = DB()->sql_fetchrowset($result);
$smile_pak = '';
for ($i = 0; $i < count($resultset); $i++)
{
$smile_pak .= $resultset[$i]['smile_url'] . $delimeter;
$smile_pak .= $resultset[$i]['emoticon'] . $delimeter;
$smile_pak .= $resultset[$i]['code'] . "\n";
}
$smile_pak = '';
for ($i = 0; $i < count($resultset); $i++) {
$smile_pak .= $resultset[$i]['smile_url'] . $delimeter;
$smile_pak .= $resultset[$i]['emoticon'] . $delimeter;
$smile_pak .= $resultset[$i]['code'] . "\n";
}
header("Content-Type: text/x-delimtext; name=\"smiles.pak\"");
header("Content-disposition: attachment; filename=smiles.pak");
header("Content-Type: text/x-delimtext; name=\"smiles.pak\"");
header("Content-disposition: attachment; filename=smiles.pak");
echo $smile_pak;
echo $smile_pak;
exit;
}
exit;
}
bb_die(sprintf($lang['EXPORT_SMILES'], '<a href="admin_smilies.php?export_pack=send">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
else if (isset($_POST['add']) || isset($_GET['add']))
{
$filename_list = '';
for ($i = 0; $i < count($smiley_images); $i++)
{
$filename_list .= '<option value="'. $smiley_images[$i] .'">'. $smiley_images[$i] .'</option>';
}
bb_die(sprintf($lang['EXPORT_SMILES'], '<a href="admin_smilies.php?export_pack=send">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} elseif (isset($_POST['add']) || isset($_GET['add'])) {
$filename_list = '';
for ($i = 0; $i < count($smiley_images); $i++) {
$filename_list .= '<option value="' . $smiley_images[$i] . '">' . $smiley_images[$i] . '</option>';
}
$s_hidden_fields = '<input type="hidden" name="mode" value="savenew" />';
$s_hidden_fields = '<input type="hidden" name="mode" value="savenew" />';
$template->assign_vars(array(
'TPL_SMILE_EDIT' => true,
'SMILEY_IMG' => BB_ROOT . $bb_cfg['smilies_path'] . '/' . $smiley_images[0],
'S_SMILEY_ACTION' => "admin_smilies.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_FILENAME_OPTIONS' => $filename_list,
'S_SMILEY_BASEDIR' => BB_ROOT . $bb_cfg['smilies_path']
));
}
else if ( $mode != '' )
{
switch( $mode )
{
case 'delete':
$smiley_id = ( !empty($_POST['id']) ) ? $_POST['id'] : $_GET['id'];
$smiley_id = intval($smiley_id);
$template->assign_vars(array(
'TPL_SMILE_EDIT' => true,
'SMILEY_IMG' => BB_ROOT . $bb_cfg['smilies_path'] . '/' . $smiley_images[0],
'S_SMILEY_ACTION' => "admin_smilies.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_FILENAME_OPTIONS' => $filename_list,
'S_SMILEY_BASEDIR' => BB_ROOT . $bb_cfg['smilies_path']
));
} elseif ($mode != '') {
switch ($mode) {
case 'delete':
$smiley_id = (!empty($_POST['id'])) ? $_POST['id'] : $_GET['id'];
$smiley_id = intval($smiley_id);
$sql = "DELETE FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id;
$result = DB()->sql_query($sql);
if (!$result)
{
bb_die('Could not delete smiley');
}
$datastore->update('smile_replacements');
$sql = "DELETE FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id;
$result = DB()->sql_query($sql);
if (!$result) {
bb_die('Could not delete smiley');
}
$datastore->update('smile_replacements');
bb_die($lang['SMILEY_DEL_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
bb_die($lang['SMILEY_DEL_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
case 'edit':
$smiley_id = ( !empty($_POST['id']) ) ? $_POST['id'] : $_GET['id'];
$smiley_id = intval($smiley_id);
case 'edit':
$smiley_id = (!empty($_POST['id'])) ? $_POST['id'] : $_GET['id'];
$smiley_id = intval($smiley_id);
$sql = "SELECT * FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id;
$result = DB()->sql_query($sql);
if (!$result)
{
bb_die('Could not obtain emoticon information');
}
$smile_data = DB()->sql_fetchrow($result);
$sql = "SELECT * FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id;
$result = DB()->sql_query($sql);
if (!$result) {
bb_die('Could not obtain emoticon information');
}
$smile_data = DB()->sql_fetchrow($result);
$filename_list = '';
for ($i = 0; $i < count($smiley_images); $i++)
{
if ($smiley_images[$i] == $smile_data['smile_url'])
{
$smiley_selected = 'selected="selected"';
$smiley_edit_img = $smiley_images[$i];
}
else
{
$smiley_selected = '';
}
$filename_list .= '<option value="' . $smiley_images[$i] . '"' . $smiley_selected . '>' . $smiley_images[$i] . '</option>';
}
$filename_list = '';
for ($i = 0; $i < count($smiley_images); $i++) {
if ($smiley_images[$i] == $smile_data['smile_url']) {
$smiley_selected = 'selected="selected"';
$smiley_edit_img = $smiley_images[$i];
} else {
$smiley_selected = '';
}
$filename_list .= '<option value="' . $smiley_images[$i] . '"' . $smiley_selected . '>' . $smiley_images[$i] . '</option>';
}
$s_hidden_fields = '<input type="hidden" name="mode" value="save" /><input type="hidden" name="smile_id" value="'. $smile_data['smilies_id'] .'" />';
$s_hidden_fields = '<input type="hidden" name="mode" value="save" /><input type="hidden" name="smile_id" value="' . $smile_data['smilies_id'] . '" />';
$template->assign_vars(array(
'TPL_SMILE_EDIT' => true,
'SMILEY_CODE' => $smile_data['code'],
'SMILEY_EMOTICON' => $smile_data['emoticon'],
'SMILEY_IMG' => BB_ROOT . $bb_cfg['smilies_path'] . '/' . $smiley_edit_img,
'S_SMILEY_ACTION' => "admin_smilies.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_FILENAME_OPTIONS' => $filename_list,
'S_SMILEY_BASEDIR' => BB_ROOT . $bb_cfg['smilies_path'],
));
$template->assign_vars(array(
'TPL_SMILE_EDIT' => true,
'SMILEY_CODE' => $smile_data['code'],
'SMILEY_EMOTICON' => $smile_data['emoticon'],
'SMILEY_IMG' => BB_ROOT . $bb_cfg['smilies_path'] . '/' . $smiley_edit_img,
'S_SMILEY_ACTION' => "admin_smilies.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_FILENAME_OPTIONS' => $filename_list,
'S_SMILEY_BASEDIR' => BB_ROOT . $bb_cfg['smilies_path'],
));
break;
break;
case 'save':
$smile_code = ( isset($_POST['smile_code']) ) ? trim($_POST['smile_code']) : trim($_GET['smile_code']);
$smile_url = ( isset($_POST['smile_url']) ) ? trim($_POST['smile_url']) : trim($_GET['smile_url']);
$smile_url = bb_ltrim(basename($smile_url), "'");
$smile_emotion = ( isset($_POST['smile_emotion']) ) ? trim($_POST['smile_emotion']) : trim($_GET['smile_emotion']);
$smile_id = ( isset($_POST['smile_id']) ) ? intval($_POST['smile_id']) : intval($_GET['smile_id']);
case 'save':
$smile_code = (isset($_POST['smile_code'])) ? trim($_POST['smile_code']) : trim($_GET['smile_code']);
$smile_url = (isset($_POST['smile_url'])) ? trim($_POST['smile_url']) : trim($_GET['smile_url']);
$smile_url = bb_ltrim(basename($smile_url), "'");
$smile_emotion = (isset($_POST['smile_emotion'])) ? trim($_POST['smile_emotion']) : trim($_GET['smile_emotion']);
$smile_id = (isset($_POST['smile_id'])) ? intval($_POST['smile_id']) : intval($_GET['smile_id']);
// If no code was entered complain
if ($smile_code == '' || $smile_url == '')
{
bb_die($lang['FIELDS_EMPTY']);
}
// If no code was entered complain
if ($smile_code == '' || $smile_url == '') {
bb_die($lang['FIELDS_EMPTY']);
}
// Convert < and > to proper htmlentities for parsing
$smile_code = str_replace('<', '&lt;', $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// Convert < and > to proper htmlentities for parsing
$smile_code = str_replace('<', '&lt;', $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// Proceed with updating the smiley table
$sql = "UPDATE " . BB_SMILIES . "
// Proceed with updating the smiley table
$sql = "UPDATE " . BB_SMILIES . "
SET code = '" . DB()->escape($smile_code) . "', smile_url = '" . DB()->escape($smile_url) . "', emoticon = '" . DB()->escape($smile_emotion) . "'
WHERE smilies_id = $smile_id";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not update smilies #2');
}
$datastore->update('smile_replacements');
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not update smilies #2');
}
$datastore->update('smile_replacements');
bb_die($lang['SMILEY_EDIT_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
bb_die($lang['SMILEY_EDIT_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
case 'savenew':
$smile_code = ( isset($_POST['smile_code']) ) ? $_POST['smile_code'] : $_GET['smile_code'];
$smile_url = ( isset($_POST['smile_url']) ) ? $_POST['smile_url'] : $_GET['smile_url'];
$smile_url = bb_ltrim(basename($smile_url), "'");
$smile_emotion = ( isset($_POST['smile_emotion']) ) ? $_POST['smile_emotion'] : $_GET['smile_emotion'];
$smile_code = trim($smile_code);
$smile_url = trim($smile_url);
$smile_emotion = trim($smile_emotion);
case 'savenew':
$smile_code = (isset($_POST['smile_code'])) ? $_POST['smile_code'] : $_GET['smile_code'];
$smile_url = (isset($_POST['smile_url'])) ? $_POST['smile_url'] : $_GET['smile_url'];
$smile_url = bb_ltrim(basename($smile_url), "'");
$smile_emotion = (isset($_POST['smile_emotion'])) ? $_POST['smile_emotion'] : $_GET['smile_emotion'];
$smile_code = trim($smile_code);
$smile_url = trim($smile_url);
$smile_emotion = trim($smile_emotion);
// If no code was entered complain
if ($smile_code == '' || $smile_url == '')
{
bb_die($lang['FIELDS_EMPTY']);
}
// If no code was entered complain
if ($smile_code == '' || $smile_url == '') {
bb_die($lang['FIELDS_EMPTY']);
}
// Convert < and > to proper htmlentities for parsing
$smile_code = str_replace('<', '&lt;', $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// Convert < and > to proper htmlentities for parsing
$smile_code = str_replace('<', '&lt;', $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// Save the data to the smiley table
$sql = "INSERT INTO " . BB_SMILIES . " (code, smile_url, emoticon)
// Save the data to the smiley table
$sql = "INSERT INTO " . BB_SMILIES . " (code, smile_url, emoticon)
VALUES ('" . DB()->escape($smile_code) . "', '" . DB()->escape($smile_url) . "', '" . DB()->escape($smile_emotion) . "')";
$result = DB()->sql_query($sql);
if (!$result)
{
bb_die('Could not insert new smiley');
}
$datastore->update('smile_replacements');
$result = DB()->sql_query($sql);
if (!$result) {
bb_die('Could not insert new smiley');
}
$datastore->update('smile_replacements');
bb_die($lang['SMILEY_ADD_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
}
}
else
{
$sql = "SELECT * FROM " . BB_SMILIES;
$result = DB()->sql_query($sql);
if (!$result)
{
bb_die('Could not obtain smileys from database');
}
bb_die($lang['SMILEY_ADD_SUCCESS'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
break;
}
} else {
$sql = "SELECT * FROM " . BB_SMILIES;
$result = DB()->sql_query($sql);
if (!$result) {
bb_die('Could not obtain smileys from database');
}
$smilies = DB()->sql_fetchrowset($result);
$smilies = DB()->sql_fetchrowset($result);
$template->assign_vars(array(
'TPL_SMILE_MAIN' => true,
'S_HIDDEN_FIELDS' => @$s_hidden_fields,
'S_SMILEY_ACTION' => 'admin_smilies.php',
));
$template->assign_vars(array(
'TPL_SMILE_MAIN' => true,
'S_HIDDEN_FIELDS' => @$s_hidden_fields,
'S_SMILEY_ACTION' => 'admin_smilies.php',
));
// Loop throuh the rows of smilies setting block vars for the template
for ($i = 0; $i < count($smilies); $i++)
{
// Replace htmlentites for < and > with actual character
$smilies[$i]['code'] = str_replace('&lt;', '<', $smilies[$i]['code']);
$smilies[$i]['code'] = str_replace('&gt;', '>', $smilies[$i]['code']);
// Loop throuh the rows of smilies setting block vars for the template
for ($i = 0; $i < count($smilies); $i++) {
// Replace htmlentites for < and > with actual character
$smilies[$i]['code'] = str_replace('&lt;', '<', $smilies[$i]['code']);
$smilies[$i]['code'] = str_replace('&gt;', '>', $smilies[$i]['code']);
$row_class = !($i % 2) ? 'row1' : 'row2';
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('smiles', array(
'ROW_CLASS' => $row_class,
$template->assign_block_vars('smiles', array(
'ROW_CLASS' => $row_class,
'SMILEY_IMG' => BB_ROOT . $bb_cfg['smilies_path'] .'/'. $smilies[$i]['smile_url'],
'CODE' => $smilies[$i]['code'],
'EMOT' => $smilies[$i]['emoticon'],
'SMILEY_IMG' => BB_ROOT . $bb_cfg['smilies_path'] . '/' . $smilies[$i]['smile_url'],
'CODE' => $smilies[$i]['code'],
'EMOT' => $smilies[$i]['emoticon'],
'U_SMILEY_EDIT' => "admin_smilies.php?mode=edit&amp;id=". $smilies[$i]['smilies_id'],
'U_SMILEY_DELETE' => "admin_smilies.php?mode=delete&amp;id=". $smilies[$i]['smilies_id'],
));
}
'U_SMILEY_EDIT' => "admin_smilies.php?mode=edit&amp;id=" . $smilies[$i]['smilies_id'],
'U_SMILEY_DELETE' => "admin_smilies.php?mode=delete&amp;id=" . $smilies[$i]['smilies_id'],
));
}
}
print_page('admin_smilies.tpl', 'admin');
print_page('admin_smilies.tpl', 'admin');

View file

@ -1,25 +1,46 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['GENERAL']['TERMS'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['GENERAL']['TERMS'] = basename(__FILE__);
return;
}
require('./pagestart.php');
require(INC_DIR .'bbcode.php');
require(INC_DIR . 'bbcode.php');
if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message'])
{
bb_update_config(array('terms' => $_POST['message']));
bb_die($lang['CONFIG_UPDATED']);
if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message']) {
bb_update_config(array('terms' => $_POST['message']));
bb_die($lang['CONFIG_UPDATED']);
}
$template->assign_vars(array(
'S_ACTION' => 'admin_terms.php',
'EXT_LINK_NW' => $bb_cfg['ext_link_new_win'],
'MESSAGE' => ($bb_cfg['terms']) ? $bb_cfg['terms'] : '',
'PREVIEW_HTML' => (isset($_REQUEST['preview'])) ? bbcode2html($_POST['message']) : '',
'S_ACTION' => 'admin_terms.php',
'EXT_LINK_NW' => $bb_cfg['ext_link_new_win'],
'MESSAGE' => ($bb_cfg['terms']) ? $bb_cfg['terms'] : '',
'PREVIEW_HTML' => (isset($_REQUEST['preview'])) ? bbcode2html($_POST['message']) : '',
));
print_page('admin_terms.tpl', 'admin');
print_page('admin_terms.tpl', 'admin');

View file

@ -1,474 +1,447 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['USERS']['PERMISSIONS'] = basename(__FILE__) .'?mode=user';
$module['GROUPS']['PERMISSIONS'] = basename(__FILE__) .'?mode=group';
return;
if (!empty($setmodules)) {
$module['USERS']['PERMISSIONS'] = basename(__FILE__) . '?mode=user';
$module['GROUPS']['PERMISSIONS'] = basename(__FILE__) . '?mode=group';
return;
}
require('./pagestart.php');
$max_forum_name_length = 50;
require(INC_DIR .'functions_group.php');
require(INC_DIR . 'functions_group.php');
$yes_sign = '&radic;';
$no_sign = 'x';
$no_sign = 'x';
$group_id = (int) @$_REQUEST['g'];
$user_id = (int) @$_REQUEST['u'];
$cat_id = (int) @$_REQUEST['c'];
$mode = (string) @$_REQUEST['mode'];
$submit = isset($_POST['submit']);
$group_id = (int)@$_REQUEST['g'];
$user_id = (int)@$_REQUEST['u'];
$cat_id = (int)@$_REQUEST['c'];
$mode = (string)@$_REQUEST['mode'];
$submit = isset($_POST['submit']);
$group_data = array();
$forum_auth_fields = array(
'auth_view',
'auth_read',
'auth_reply',
'auth_edit',
'auth_delete',
'auth_vote',
'auth_pollcreate',
'auth_attachments',
'auth_download',
'auth_post',
'auth_sticky',
'auth_announce',
'auth_view',
'auth_read',
'auth_reply',
'auth_edit',
'auth_delete',
'auth_vote',
'auth_pollcreate',
'auth_attachments',
'auth_download',
'auth_post',
'auth_sticky',
'auth_announce',
);
if ($submit && $mode == 'user')
{
$this_user_level = null;
if ($submit && $mode == 'user') {
$this_user_level = null;
// Obtain relevant data for this user
if (!$row = get_userdata($user_id))
{
bb_die($lang['NO_SUCH_USER']);
}
$this_user_level = $row['user_level'];
// Obtain relevant data for this user
if (!$row = get_userdata($user_id)) {
bb_die($lang['NO_SUCH_USER']);
}
$this_user_level = $row['user_level'];
// Get "single_user" group_id for this user
$sql = "SELECT g.group_id
FROM ". BB_USER_GROUP ." ug, ". BB_GROUPS ." g
// Get "single_user" group_id for this user
$sql = "SELECT g.group_id
FROM " . BB_USER_GROUP . " ug, " . BB_GROUPS . " g
WHERE ug.user_id = $user_id
AND g.group_id = ug.group_id
AND g.group_single_user = 1";
if ($row = DB()->fetch_row($sql))
{
$group_id = $row['group_id'];
}
else
{
$group_id = create_user_group($user_id);
}
if ($row = DB()->fetch_row($sql)) {
$group_id = $row['group_id'];
} else {
$group_id = create_user_group($user_id);
}
if (!$group_id || !$user_id || is_null($this_user_level))
{
trigger_error('data missing', E_USER_ERROR);
}
if (!$group_id || !$user_id || is_null($this_user_level)) {
trigger_error('data missing', E_USER_ERROR);
}
// Make user an admin (if already user)
if (@$_POST['userlevel'] === 'admin')
{
if ($userdata['user_id'] == $user_id || $user_id == GUEST_UID || $user_id == BOT_UID)
{
bb_die("Could not update admin status");
}
// Make user an admin (if already user)
if (@$_POST['userlevel'] === 'admin') {
if ($userdata['user_id'] == $user_id || $user_id == GUEST_UID || $user_id == BOT_UID) {
bb_die("Could not update admin status");
}
DB()->query("UPDATE ". BB_USERS ." SET user_level = ". ADMIN ." WHERE user_id = $user_id LIMIT 1");
DB()->query("UPDATE " . BB_USERS . " SET user_level = " . ADMIN . " WHERE user_id = $user_id LIMIT 1");
// Delete any entries in auth_access, they are not required if user is becoming an admin
delete_permissions($group_id, $user_id);
// Delete any entries in auth_access, they are not required if user is becoming an admin
delete_permissions($group_id, $user_id);
$message = $lang['AUTH_UPDATED'] .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '<a href="admin_ug_auth.php?mode='. $mode .'">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$message = $lang['AUTH_UPDATED'] . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '<a href="admin_ug_auth.php?mode=' . $mode . '">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
// Make admin a user (if already admin)
else if (@$_POST['userlevel'] === 'user')
{
// ignore if you're trying to change yourself from an admin to user!
if ($userdata['user_id'] == $user_id)
{
bb_die("Could not update admin status<br /><br />Could not change yourself from an admin to user");
}
// Update users level, reset to USER
DB()->query("UPDATE ". BB_USERS ." SET user_level = ". USER ." WHERE user_id = $user_id LIMIT 1");
bb_die($message);
} // Make admin a user (if already admin)
elseif (@$_POST['userlevel'] === 'user') {
// ignore if you're trying to change yourself from an admin to user!
if ($userdata['user_id'] == $user_id) {
bb_die("Could not update admin status<br /><br />Could not change yourself from an admin to user");
}
// Update users level, reset to USER
DB()->query("UPDATE " . BB_USERS . " SET user_level = " . USER . " WHERE user_id = $user_id LIMIT 1");
delete_permissions($group_id, $user_id);
delete_permissions($group_id, $user_id);
$message = $lang['AUTH_UPDATED'] .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '<a href="admin_ug_auth.php?mode='. $mode .'">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$message = $lang['AUTH_UPDATED'] . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '<a href="admin_ug_auth.php?mode=' . $mode . '">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
bb_die($message);
}
//
// Submit new USER permissions
//
$auth = array();
//
// Submit new USER permissions
//
$auth = array();
if (is_array(@$_POST['auth']))
{
array_deep($_POST['auth'], 'intval');
if (is_array(@$_POST['auth'])) {
array_deep($_POST['auth'], 'intval');
foreach ($_POST['auth'] as $f_id => $bf_ary)
{
if (array_sum($bf_ary))
{
$auth[$f_id] = bit2dec(array_keys($bf_ary, 1));
}
}
}
foreach ($_POST['auth'] as $f_id => $bf_ary) {
if (array_sum($bf_ary)) {
$auth[$f_id] = bit2dec(array_keys($bf_ary, 1));
}
}
}
delete_permissions($group_id, null, $cat_id);
store_permissions($group_id, $auth);
delete_permissions($group_id, null, $cat_id);
store_permissions($group_id, $auth);
update_user_level($user_id);
update_user_level($user_id);
$l_auth_return = ($mode == 'user') ? $lang['CLICK_RETURN_USERAUTH'] : $lang['CLICK_RETURN_GROUPAUTH'];
$message = $lang['AUTH_UPDATED'] .'<br /><br />';
$message .= sprintf($l_auth_return, '<a href="admin_ug_auth.php?mode='. $mode .'">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$l_auth_return = ($mode == 'user') ? $lang['CLICK_RETURN_USERAUTH'] : $lang['CLICK_RETURN_GROUPAUTH'];
$message = $lang['AUTH_UPDATED'] . '<br /><br />';
$message .= sprintf($l_auth_return, '<a href="admin_ug_auth.php?mode=' . $mode . '">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
bb_die($message);
}
//
// Submit new GROUP permissions
//
else if ($submit && $mode == 'group' && is_array(@$_POST['auth']))
{
if (!$group_data = get_group_data($group_id))
{
bb_die($lang['GROUP_NOT_EXIST']);
}
elseif ($submit && $mode == 'group' && is_array(@$_POST['auth'])) {
if (!$group_data = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
$auth = array();
array_deep($_POST['auth'], 'intval');
$auth = array();
array_deep($_POST['auth'], 'intval');
foreach ($_POST['auth'] as $f_id => $bf_ary)
{
if (array_sum($bf_ary))
{
$auth[$f_id] = bit2dec(array_keys($bf_ary, 1));
}
}
foreach ($_POST['auth'] as $f_id => $bf_ary) {
if (array_sum($bf_ary)) {
$auth[$f_id] = bit2dec(array_keys($bf_ary, 1));
}
}
delete_permissions($group_id, null, $cat_id);
store_permissions($group_id, $auth);
delete_permissions($group_id, null, $cat_id);
store_permissions($group_id, $auth);
update_user_level('all');
update_user_level('all');
$l_auth_return = $lang['CLICK_RETURN_GROUPAUTH'];
$message = $lang['AUTH_UPDATED'] .'<br /><br />';
$message .= sprintf($l_auth_return, '<a href="admin_ug_auth.php?mode='. $mode .'">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
$l_auth_return = $lang['CLICK_RETURN_GROUPAUTH'];
$message = $lang['AUTH_UPDATED'] . '<br /><br />';
$message .= sprintf($l_auth_return, '<a href="admin_ug_auth.php?mode=' . $mode . '">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
bb_die($message);
}
//
// Front end (changing permissions)
//
if ($mode == 'user' && (!empty($_POST['username']) || $user_id))
{
$page_cfg['quirks_mode'] = true;
if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) {
$page_cfg['quirks_mode'] = true;
if (!empty($_POST['username']))
{
$this_userdata = get_userdata($_POST['username'], true);
$user_id = $this_userdata['user_id'];
}
else
{
$this_userdata = get_userdata($user_id);
}
if (!$this_userdata)
{
bb_die($lang['NO_SUCH_USER']);
}
if (!empty($_POST['username'])) {
$this_userdata = get_userdata($_POST['username'], true);
$user_id = $this_userdata['user_id'];
} else {
$this_userdata = get_userdata($user_id);
}
if (!$this_userdata) {
bb_die($lang['NO_SUCH_USER']);
}
if (!$forums = $datastore->get('cat_forums'))
{
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$base_url = basename(__FILE__) ."?mode=user&amp;u=$user_id";
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$base_url = basename(__FILE__) . "?mode=user&amp;u=$user_id";
$ug_data = $this_userdata;
$ug_data['session_logged_in'] = 1;
$ug_data = $this_userdata;
$ug_data['session_logged_in'] = 1;
$u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_USER_ONLY);
$g_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_GROUP_ONLY);
$u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_USER_ONLY);
$g_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_GROUP_ONLY);
foreach ($forums['c'] as $c_id => $c_data)
{
$template->assign_block_vars('c', array(
'CAT_ID' => $c_id,
'CAT_TITLE' => $forums['cat_title_html'][$c_id],
'CAT_HREF' => "$base_url&amp;c=$c_id",
));
foreach ($forums['c'] as $c_id => $c_data) {
$template->assign_block_vars('c', array(
'CAT_ID' => $c_id,
'CAT_TITLE' => $forums['cat_title_html'][$c_id],
'CAT_HREF' => "$base_url&amp;c=$c_id",
));
if (!$c =& $_REQUEST['c'] OR !in_array($c, array('all', $c_id)) OR empty($c_data['forums']))
{
continue;
}
if (!$c =& $_REQUEST['c'] or !in_array($c, array('all', $c_id)) or empty($c_data['forums'])) {
continue;
}
foreach ($c_data['forums'] as $f_id)
{
$f_data = $forums['f'][$f_id];
$auth_mod = ($u_access[$f_id]['auth_mod'] || $g_access[$f_id]['auth_mod']);
$disabled = $g_access[$f_id]['auth_mod'];
foreach ($c_data['forums'] as $f_id) {
$f_data = $forums['f'][$f_id];
$auth_mod = ($u_access[$f_id]['auth_mod'] || $g_access[$f_id]['auth_mod']);
$disabled = $g_access[$f_id]['auth_mod'];
$template->assign_block_vars('c.f', array(
'DISABLED' => $disabled,
'FORUM_ID' => $f_id,
'FORUM_NAME' => str_short($forums['forum_name_html'][$f_id], $max_forum_name_length),
'SF_SPACER' => ($f_data['forum_parent']) ? HTML_SF_SPACER : '',
'IS_MODERATOR' => (bool) $auth_mod,
'MOD_STATUS' => ($auth_mod) ? $lang['MODERATOR'] : $lang['NONE'],
'MOD_CLASS' => ($auth_mod) ? (($disabled) ? 'yesDisabled' : 'yesMOD') : 'noMOD',
'AUTH_MOD_VAL' => ($auth_mod) ? 1 : 0,
));
$template->assign_block_vars('c.f', array(
'DISABLED' => $disabled,
'FORUM_ID' => $f_id,
'FORUM_NAME' => str_short($forums['forum_name_html'][$f_id], $max_forum_name_length),
'SF_SPACER' => ($f_data['forum_parent']) ? HTML_SF_SPACER : '',
'IS_MODERATOR' => (bool)$auth_mod,
'MOD_STATUS' => ($auth_mod) ? $lang['MODERATOR'] : $lang['NONE'],
'MOD_CLASS' => ($auth_mod) ? (($disabled) ? 'yesDisabled' : 'yesMOD') : 'noMOD',
'AUTH_MOD_VAL' => ($auth_mod) ? 1 : 0,
));
foreach ($forum_auth_fields as $auth_type)
{
$bf_num = $bf['forum_perm'][$auth_type];
$f_perm = $f_data[$auth_type];
$auth_via_acl = ($u_access[$f_id][$auth_type] || $g_access[$f_id][$auth_type]);
foreach ($forum_auth_fields as $auth_type) {
$bf_num = $bf['forum_perm'][$auth_type];
$f_perm = $f_data[$auth_type];
$auth_via_acl = ($u_access[$f_id][$auth_type] || $g_access[$f_id][$auth_type]);
if ($f_perm == AUTH_ACL)
{
$disabled = ($auth_mod || $g_access[$f_id][$auth_type]);
$perm_sign = ($auth_via_acl || $auth_mod) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl || $auth_mod) ? 'yes' : 'no';
}
else
{
$disabled = true;
$perm_sign = ($auth_via_acl) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl) ? 'yes' : 'no';
}
if ($f_perm == AUTH_ACL) {
$disabled = ($auth_mod || $g_access[$f_id][$auth_type]);
$perm_sign = ($auth_via_acl || $auth_mod) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl || $auth_mod) ? 'yes' : 'no';
} else {
$disabled = true;
$perm_sign = ($auth_via_acl) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl) ? 'yes' : 'no';
}
$template->assign_block_vars('c.f.acl', array(
'DISABLED' => $disabled,
'PERM_SIGN' => $perm_sign,
'ACL_CLASS' => $acl_class,
'FORUM_ID' => $f_id,
'ACL_TYPE_BF' => $bf_num,
'ACL_VAL' => ($auth_via_acl) ? 1 : 0,
));
}
}
}
$template->assign_block_vars('c.f.acl', array(
'DISABLED' => $disabled,
'PERM_SIGN' => $perm_sign,
'ACL_CLASS' => $acl_class,
'FORUM_ID' => $f_id,
'ACL_TYPE_BF' => $bf_num,
'ACL_VAL' => ($auth_via_acl) ? 1 : 0,
));
}
}
}
$template->assign_vars(array(
'AUTH_MOD_BF' => AUTH_MOD,
));
$template->assign_vars(array(
'AUTH_MOD_BF' => AUTH_MOD,
));
$s_column_span = 2;
$s_column_span = 2;
foreach ($forum_auth_fields as $auth_type)
{
$template->assign_block_vars('acltype', array(
'ACL_TYPE_NAME' => preg_replace("#(.{5})#u", "\\1<br />", $lang[strtoupper($auth_type)]),
'ACL_TYPE_BF' => $bf['forum_perm'][$auth_type],
));
$s_column_span++;
}
foreach ($forum_auth_fields as $auth_type) {
$template->assign_block_vars('acltype', array(
'ACL_TYPE_NAME' => preg_replace("#(.{5})#u", "\\1<br />", $lang[strtoupper($auth_type)]),
'ACL_TYPE_BF' => $bf['forum_perm'][$auth_type],
));
$s_column_span++;
}
unset($forums, $u_access, $g_access);
$datastore->rm('cat_forums');
unset($forums, $u_access, $g_access);
$datastore->rm('cat_forums');
$s_hidden_fields = '
<input type="hidden" name="mode" value="'. $mode .'" />
<input type="hidden" name="'. POST_USERS_URL .'" value="'. $user_id .'" />
$s_hidden_fields = '
<input type="hidden" name="mode" value="' . $mode . '" />
<input type="hidden" name="' . POST_USERS_URL . '" value="' . $user_id . '" />
';
$s_user_type = ($this_userdata['user_level'] == ADMIN) ? '
$s_user_type = ($this_userdata['user_level'] == ADMIN) ? '
<select name="userlevel">
<option value="admin" selected="selected">'. $lang['AUTH_ADMIN'] .'</option>
<option value="user">'. $lang['AUTH_USER'] .'</option>
<option value="admin" selected="selected">' . $lang['AUTH_ADMIN'] . '</option>
<option value="user">' . $lang['AUTH_USER'] . '</option>
</select>
' : '
<select name="userlevel">
<option value="admin">'. $lang['AUTH_ADMIN'] .'</option>
<option value="user" selected="selected">'. $lang['AUTH_USER'] .'</option>
<option value="admin">' . $lang['AUTH_ADMIN'] . '</option>
<option value="user" selected="selected">' . $lang['AUTH_USER'] . '</option>
</select>
';
$template->assign_block_vars('switch_user_auth', array());
$template->assign_block_vars('switch_user_auth', array());
$template->assign_vars(array(
'TPL_AUTH_UG_MAIN' => true,
$template->assign_vars(array(
'TPL_AUTH_UG_MAIN' => true,
'USER_OR_GROUPNAME' => $this_userdata['username'],
'USER_LEVEL' => $lang['USER_LEVEL'] .' : '. $s_user_type,
'USER_GROUP_MEMBERSHIPS' => $lang['GROUP_MEMBERSHIPS'],
));
'USER_OR_GROUPNAME' => $this_userdata['username'],
'USER_LEVEL' => $lang['USER_LEVEL'] . ' : ' . $s_user_type,
'USER_GROUP_MEMBERSHIPS' => $lang['GROUP_MEMBERSHIPS'],
));
$template->assign_vars(array(
'T_USER_OR_GROUPNAME' => $lang['USERNAME'],
'T_AUTH_TITLE' => $lang['AUTH_CONTROL_USER'],
'T_AUTH_EXPLAIN' => $lang['USER_AUTH_EXPLAIN'],
$template->assign_vars(array(
'T_USER_OR_GROUPNAME' => $lang['USERNAME'],
'T_AUTH_TITLE' => $lang['AUTH_CONTROL_USER'],
'T_AUTH_EXPLAIN' => $lang['USER_AUTH_EXPLAIN'],
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else if ($mode == 'group' && $group_id)
{
$page_cfg['quirks_mode'] = true;
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
} elseif ($mode == 'group' && $group_id) {
$page_cfg['quirks_mode'] = true;
if (!$group_data = get_group_data($group_id))
{
bb_die($lang['GROUP_NOT_EXIST']);
}
if (!$group_data = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
if (!$forums = $datastore->get('cat_forums'))
{
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$base_url = basename(__FILE__) ."?mode=group&amp;g=$group_id";
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$base_url = basename(__FILE__) . "?mode=group&amp;g=$group_id";
$ug_data = array('group_id' => $group_id);
$u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data);
$ug_data = array('group_id' => $group_id);
$u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data);
foreach ($forums['c'] as $c_id => $c_data)
{
$template->assign_block_vars('c', array(
'CAT_ID' => $c_id,
'CAT_TITLE' => $forums['cat_title_html'][$c_id],
'CAT_HREF' => "$base_url&amp;c=$c_id",
));
foreach ($forums['c'] as $c_id => $c_data) {
$template->assign_block_vars('c', array(
'CAT_ID' => $c_id,
'CAT_TITLE' => $forums['cat_title_html'][$c_id],
'CAT_HREF' => "$base_url&amp;c=$c_id",
));
if (!$c =& $_REQUEST['c'] OR !in_array($c, array('all', $c_id)) OR empty($c_data['forums']))
{
continue;
}
if (!$c =& $_REQUEST['c'] or !in_array($c, array('all', $c_id)) or empty($c_data['forums'])) {
continue;
}
foreach ($c_data['forums'] as $f_id)
{
$f_data = $forums['f'][$f_id];
$auth_mod = $u_access[$f_id]['auth_mod'];
foreach ($c_data['forums'] as $f_id) {
$f_data = $forums['f'][$f_id];
$auth_mod = $u_access[$f_id]['auth_mod'];
$template->assign_block_vars('c.f', array(
'DISABLED' => false,
'FORUM_ID' => $f_id,
'FORUM_NAME' => str_short($forums['forum_name_html'][$f_id], $max_forum_name_length),
'SF_SPACER' => ($f_data['forum_parent']) ? HTML_SF_SPACER : '',
'IS_MODERATOR' => (bool) $auth_mod,
'MOD_STATUS' => ($auth_mod) ? $lang['MODERATOR'] : $lang['NO'],
'MOD_CLASS' => ($auth_mod) ? 'yesMOD' : 'noMOD',
'AUTH_MOD_VAL' => ($auth_mod) ? 1 : 0,
));
$template->assign_block_vars('c.f', array(
'DISABLED' => false,
'FORUM_ID' => $f_id,
'FORUM_NAME' => str_short($forums['forum_name_html'][$f_id], $max_forum_name_length),
'SF_SPACER' => ($f_data['forum_parent']) ? HTML_SF_SPACER : '',
'IS_MODERATOR' => (bool)$auth_mod,
'MOD_STATUS' => ($auth_mod) ? $lang['MODERATOR'] : $lang['NO'],
'MOD_CLASS' => ($auth_mod) ? 'yesMOD' : 'noMOD',
'AUTH_MOD_VAL' => ($auth_mod) ? 1 : 0,
));
foreach ($forum_auth_fields as $auth_type)
{
$bf_num = $bf['forum_perm'][$auth_type];
$f_perm = $f_data[$auth_type];
$auth_via_acl = $u_access[$f_id][$auth_type];
foreach ($forum_auth_fields as $auth_type) {
$bf_num = $bf['forum_perm'][$auth_type];
$f_perm = $f_data[$auth_type];
$auth_via_acl = $u_access[$f_id][$auth_type];
if ($f_perm == AUTH_ACL)
{
$disabled = $auth_mod;
$perm_sign = ($auth_via_acl || $auth_mod) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl || $auth_mod) ? 'yes' : 'no';
}
else
{
$disabled = true;
$perm_sign = ($auth_via_acl) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl) ? 'yes' : 'no';
}
if ($f_perm == AUTH_ACL) {
$disabled = $auth_mod;
$perm_sign = ($auth_via_acl || $auth_mod) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl || $auth_mod) ? 'yes' : 'no';
} else {
$disabled = true;
$perm_sign = ($auth_via_acl) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl) ? 'yes' : 'no';
}
$template->assign_block_vars('c.f.acl', array(
'DISABLED' => $disabled,
'PERM_SIGN' => $perm_sign,
'ACL_CLASS' => $acl_class,
'FORUM_ID' => $f_id,
'ACL_TYPE_BF' => $bf_num,
'ACL_VAL' => ($auth_via_acl) ? 1 : 0,
));
}
}
}
$template->assign_block_vars('c.f.acl', array(
'DISABLED' => $disabled,
'PERM_SIGN' => $perm_sign,
'ACL_CLASS' => $acl_class,
'FORUM_ID' => $f_id,
'ACL_TYPE_BF' => $bf_num,
'ACL_VAL' => ($auth_via_acl) ? 1 : 0,
));
}
}
}
$template->assign_vars(array(
'AUTH_MOD_BF' => AUTH_MOD,
));
$template->assign_vars(array(
'AUTH_MOD_BF' => AUTH_MOD,
));
$s_column_span = 2;
$s_column_span = 2;
foreach ($forum_auth_fields as $auth_type)
{
$template->assign_block_vars('acltype', array(
'ACL_TYPE_NAME' => preg_replace("#(.{5})#u", "\\1<br />", $lang[strtoupper($auth_type)]),
'ACL_TYPE_BF' => $bf['forum_perm'][$auth_type],
));
$s_column_span++;
}
foreach ($forum_auth_fields as $auth_type) {
$template->assign_block_vars('acltype', array(
'ACL_TYPE_NAME' => preg_replace("#(.{5})#u", "\\1<br />", $lang[strtoupper($auth_type)]),
'ACL_TYPE_BF' => $bf['forum_perm'][$auth_type],
));
$s_column_span++;
}
unset($forums, $ug_data, $u_access);
$datastore->rm('cat_forums');
unset($forums, $ug_data, $u_access);
$datastore->rm('cat_forums');
$s_hidden_fields = '
<input type="hidden" name="mode" value="'. $mode .'" />
<input type="hidden" name="g" value="'. $group_id .'" />
$s_hidden_fields = '
<input type="hidden" name="mode" value="' . $mode . '" />
<input type="hidden" name="g" value="' . $group_id . '" />
';
$template->assign_vars(array(
'TPL_AUTH_UG_MAIN' => true,
$template->assign_vars(array(
'TPL_AUTH_UG_MAIN' => true,
'T_USER_OR_GROUPNAME' => $lang['GROUP_NAME'],
'USER_LEVEL' => false,
'T_AUTH_TITLE' => $lang['AUTH_CONTROL_GROUP'],
'T_AUTH_EXPLAIN' => $lang['GROUP_AUTH_EXPLAIN'],
'USER_OR_GROUPNAME' => htmlCHR($group_data['group_name']),
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else
{
// Select a user/group
if ($mode == 'user')
{
$template->assign_vars(array(
'TPL_SELECT_USER' => true,
'U_SEARCH_USER' => BB_ROOT ."search.php?mode=searchuser",
));
}
else
{
$template->assign_vars(array(
'TPL_SELECT_GROUP' => true,
'S_GROUP_SELECT' => get_select('groups'),
));
}
'T_USER_OR_GROUPNAME' => $lang['GROUP_NAME'],
'USER_LEVEL' => false,
'T_AUTH_TITLE' => $lang['AUTH_CONTROL_GROUP'],
'T_AUTH_EXPLAIN' => $lang['GROUP_AUTH_EXPLAIN'],
'USER_OR_GROUPNAME' => htmlCHR($group_data['group_name']),
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
} else {
// Select a user/group
if ($mode == 'user') {
$template->assign_vars(array(
'TPL_SELECT_USER' => true,
'U_SEARCH_USER' => BB_ROOT . "search.php?mode=searchuser",
));
} else {
$template->assign_vars(array(
'TPL_SELECT_GROUP' => true,
'S_GROUP_SELECT' => get_select('groups'),
));
}
$s_hidden_fields = '<input type="hidden" name="mode" value="'. $mode .'" />';
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';
$template->assign_vars(array(
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
$template->assign_vars(array(
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
$template->assign_vars(array(
'YES_SIGN' => $yes_sign,
'NO_SIGN' => $no_sign,
'T_MOD_YES' => $lang['MODERATOR'],
'T_MOD_NO' => $lang['NO'],
'S_AUTH_ACTION' => "admin_ug_auth.php",
'SELECTED_CAT' => !empty($_REQUEST['c']) ? $_REQUEST['c'] : '',
'U_ALL_FORUMS' => !empty($base_url) ? "$base_url&amp;c=all" : '',
'YES_SIGN' => $yes_sign,
'NO_SIGN' => $no_sign,
'T_MOD_YES' => $lang['MODERATOR'],
'T_MOD_NO' => $lang['NO'],
'S_AUTH_ACTION' => "admin_ug_auth.php",
'SELECTED_CAT' => !empty($_REQUEST['c']) ? $_REQUEST['c'] : '',
'U_ALL_FORUMS' => !empty($base_url) ? "$base_url&amp;c=all" : '',
));
print_page('admin_ug_auth.tpl', 'admin');
print_page('admin_ug_auth.tpl', 'admin');

View file

@ -1,362 +1,318 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['USERS']['BAN_MANAGEMENT'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['USERS']['BAN_MANAGEMENT'] = basename(__FILE__);
return;
}
require('./pagestart.php');
if (isset($_POST['submit']))
{
$user_bansql = '';
$email_bansql = '';
$ip_bansql = '';
if (isset($_POST['submit'])) {
$user_bansql = '';
$email_bansql = '';
$ip_bansql = '';
$user_list = array();
if (!empty($_POST['username']))
{
$this_userdata = get_userdata($_POST['username'], true);
if (!$this_userdata)
{
bb_die($lang['NO_USER_ID_SPECIFIED']);
}
$user_list = array();
if (!empty($_POST['username'])) {
$this_userdata = get_userdata($_POST['username'], true);
if (!$this_userdata) {
bb_die($lang['NO_USER_ID_SPECIFIED']);
}
$user_list[] = $this_userdata['user_id'];
}
$user_list[] = $this_userdata['user_id'];
}
$ip_list = array();
if (isset($_POST['ban_ip']))
{
$ip_list_temp = explode(',', $_POST['ban_ip']);
$ip_list = array();
if (isset($_POST['ban_ip'])) {
$ip_list_temp = explode(',', $_POST['ban_ip']);
for ($i = 0; $i < count($ip_list_temp); $i++)
{
if (preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', trim($ip_list_temp[$i]), $ip_range_explode))
{
$ip_1_counter = $ip_range_explode[1];
$ip_1_end = $ip_range_explode[5];
for ($i = 0; $i < count($ip_list_temp); $i++) {
if (preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', trim($ip_list_temp[$i]), $ip_range_explode)) {
$ip_1_counter = $ip_range_explode[1];
$ip_1_end = $ip_range_explode[5];
while ( $ip_1_counter <= $ip_1_end )
{
$ip_2_counter = ( $ip_1_counter == $ip_range_explode[1] ) ? $ip_range_explode[2] : 0;
$ip_2_end = ( $ip_1_counter < $ip_1_end ) ? 254 : $ip_range_explode[6];
while ($ip_1_counter <= $ip_1_end) {
$ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0;
$ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6];
if ( $ip_2_counter == 0 && $ip_2_end == 254 )
{
$ip_2_counter = 255;
$ip_2_fragment = 255;
if ($ip_2_counter == 0 && $ip_2_end == 254) {
$ip_2_counter = 255;
$ip_2_fragment = 255;
$ip_list[] = encode_ip("$ip_1_counter.255.255.255");
}
$ip_list[] = encode_ip("$ip_1_counter.255.255.255");
}
while ( $ip_2_counter <= $ip_2_end )
{
$ip_3_counter = ( $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1] ) ? $ip_range_explode[3] : 0;
$ip_3_end = ( $ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end ) ? 254 : $ip_range_explode[7];
while ($ip_2_counter <= $ip_2_end) {
$ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0;
$ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7];
if ( $ip_3_counter == 0 && $ip_3_end == 254 )
{
$ip_3_counter = 255;
$ip_3_fragment = 255;
if ($ip_3_counter == 0 && $ip_3_end == 254) {
$ip_3_counter = 255;
$ip_3_fragment = 255;
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.255.255");
}
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.255.255");
}
while ( $ip_3_counter <= $ip_3_end )
{
$ip_4_counter = ( $ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1] ) ? $ip_range_explode[4] : 0;
$ip_4_end = ( $ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end ) ? 254 : $ip_range_explode[8];
while ($ip_3_counter <= $ip_3_end) {
$ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0;
$ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8];
if ( $ip_4_counter == 0 && $ip_4_end == 254 )
{
$ip_4_counter = 255;
$ip_4_fragment = 255;
if ($ip_4_counter == 0 && $ip_4_end == 254) {
$ip_4_counter = 255;
$ip_4_fragment = 255;
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.$ip_3_counter.255");
}
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.$ip_3_counter.255");
}
while ( $ip_4_counter <= $ip_4_end )
{
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter");
$ip_4_counter++;
}
$ip_3_counter++;
}
$ip_2_counter++;
}
$ip_1_counter++;
}
}
else if (preg_match('/^([\w\-_]\.?){2,}$/is', trim($ip_list_temp[$i])))
{
$ip = gethostbynamel(trim($ip_list_temp[$i]));
while ($ip_4_counter <= $ip_4_end) {
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter");
$ip_4_counter++;
}
$ip_3_counter++;
}
$ip_2_counter++;
}
$ip_1_counter++;
}
} elseif (preg_match('/^([\w\-_]\.?){2,}$/is', trim($ip_list_temp[$i]))) {
$ip = gethostbynamel(trim($ip_list_temp[$i]));
for ($j = 0; $j < count($ip); $j++)
{
if (!empty($ip[$j]))
{
$ip_list[] = encode_ip($ip[$j]);
}
}
}
else if (preg_match('/^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$/', trim($ip_list_temp[$i])))
{
$ip_list[] = encode_ip(str_replace('*', '255', trim($ip_list_temp[$i])));
}
}
}
for ($j = 0; $j < count($ip); $j++) {
if (!empty($ip[$j])) {
$ip_list[] = encode_ip($ip[$j]);
}
}
} elseif (preg_match('/^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$/', trim($ip_list_temp[$i]))) {
$ip_list[] = encode_ip(str_replace('*', '255', trim($ip_list_temp[$i])));
}
}
}
$email_list = array();
if (isset($_POST['ban_email']))
{
$email_list_temp = explode(',', $_POST['ban_email']);
$email_list = array();
if (isset($_POST['ban_email'])) {
$email_list_temp = explode(',', $_POST['ban_email']);
for ($i = 0; $i < count($email_list_temp); $i++)
{
if (preg_match('/^(([a-z0-9&\'\.\-_\+])|(\*))+@(([a-z0-9\-])|(\*))+\.([a-z0-9\-]+\.)*?[a-z]+$/is', trim($email_list_temp[$i])))
{
$email_list[] = trim($email_list_temp[$i]);
}
}
}
for ($i = 0; $i < count($email_list_temp); $i++) {
if (preg_match('/^(([a-z0-9&\'\.\-_\+])|(\*))+@(([a-z0-9\-])|(\*))+\.([a-z0-9\-]+\.)*?[a-z]+$/is', trim($email_list_temp[$i]))) {
$email_list[] = trim($email_list_temp[$i]);
}
}
}
$sql = "SELECT * FROM " . BB_BANLIST;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not obtain banlist information');
}
$sql = "SELECT * FROM " . BB_BANLIST;
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain banlist information');
}
$current_banlist = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
$current_banlist = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
$kill_session_sql = '';
for ($i = 0; $i < count($user_list); $i++)
{
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++)
{
if ($user_list[$i] == $current_banlist[$j]['ban_userid'])
{
$in_banlist = true;
}
}
$kill_session_sql = '';
for ($i = 0; $i < count($user_list); $i++) {
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++) {
if ($user_list[$i] == $current_banlist[$j]['ban_userid']) {
$in_banlist = true;
}
}
if (!$in_banlist)
{
$kill_session_sql .= ( ( $kill_session_sql != '' ) ? ' OR ' : '' ) . "session_user_id = " . $user_list[$i];
if (!$in_banlist) {
$kill_session_sql .= (($kill_session_sql != '') ? ' OR ' : '') . "session_user_id = " . $user_list[$i];
$sql = "INSERT INTO " . BB_BANLIST . " (ban_userid) VALUES (" . $user_list[$i] . ")";
if (!DB()->sql_query($sql))
{
bb_die('Could not insert ban_userid info into database');
}
}
}
$sql = "INSERT INTO " . BB_BANLIST . " (ban_userid) VALUES (" . $user_list[$i] . ")";
if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_userid info into database');
}
}
}
for ($i = 0; $i < count($ip_list); $i++)
{
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++)
{
if ($ip_list[$i] == $current_banlist[$j]['ban_ip'])
{
$in_banlist = true;
}
}
for ($i = 0; $i < count($ip_list); $i++) {
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++) {
if ($ip_list[$i] == $current_banlist[$j]['ban_ip']) {
$in_banlist = true;
}
}
if (!$in_banlist)
{
if (preg_match('/(ff\.)|(\.ff)/is', chunk_split($ip_list[$i], 2, '.')))
{
$kill_ip_sql = "session_ip LIKE '" . str_replace('.', '', preg_replace('/(ff\.)|(\.ff)/is', '%', chunk_split($ip_list[$i], 2, "."))) . "'";
}
else
{
$kill_ip_sql = "session_ip = '" . $ip_list[$i] . "'";
}
if (!$in_banlist) {
if (preg_match('/(ff\.)|(\.ff)/is', chunk_split($ip_list[$i], 2, '.'))) {
$kill_ip_sql = "session_ip LIKE '" . str_replace('.', '', preg_replace('/(ff\.)|(\.ff)/is', '%', chunk_split($ip_list[$i], 2, "."))) . "'";
} else {
$kill_ip_sql = "session_ip = '" . $ip_list[$i] . "'";
}
$kill_session_sql .= ( ( $kill_session_sql != '' ) ? ' OR ' : '' ) . $kill_ip_sql;
$kill_session_sql .= (($kill_session_sql != '') ? ' OR ' : '') . $kill_ip_sql;
$sql = "INSERT INTO " . BB_BANLIST . " (ban_ip) VALUES ('" . $ip_list[$i] . "')";
if ( !DB()->sql_query($sql) )
{
bb_die('Could not insert ban_ip info into database');
}
}
}
$sql = "INSERT INTO " . BB_BANLIST . " (ban_ip) VALUES ('" . $ip_list[$i] . "')";
if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_ip info into database');
}
}
}
// Now we'll delete all entries from the session table
if ($kill_session_sql != '')
{
$sql = "DELETE FROM " . BB_SESSIONS . " WHERE $kill_session_sql";
if (!DB()->sql_query($sql))
{
bb_die('Could not delete banned sessions from database');
}
}
// Now we'll delete all entries from the session table
if ($kill_session_sql != '') {
$sql = "DELETE FROM " . BB_SESSIONS . " WHERE $kill_session_sql";
if (!DB()->sql_query($sql)) {
bb_die('Could not delete banned sessions from database');
}
}
for ($i = 0; $i < count($email_list); $i++)
{
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++)
{
if ($email_list[$i] == $current_banlist[$j]['ban_email'])
{
$in_banlist = true;
}
}
for ($i = 0; $i < count($email_list); $i++) {
$in_banlist = false;
for ($j = 0; $j < count($current_banlist); $j++) {
if ($email_list[$i] == $current_banlist[$j]['ban_email']) {
$in_banlist = true;
}
}
if (!$in_banlist)
{
$sql = "INSERT INTO " . BB_BANLIST . " (ban_email) VALUES ('" . DB()->escape($email_list[$i]) . "')";
if (!DB()->sql_query($sql))
{
bb_die('Could not insert ban_email info into database');
}
}
}
if (!$in_banlist) {
$sql = "INSERT INTO " . BB_BANLIST . " (ban_email) VALUES ('" . DB()->escape($email_list[$i]) . "')";
if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_email info into database');
}
}
}
$where_sql = '';
$where_sql = '';
if (isset($_POST['unban_user']))
{
$user_list = $_POST['unban_user'];
if (isset($_POST['unban_user'])) {
$user_list = $_POST['unban_user'];
for ($i = 0; $i < count($user_list); $i++)
{
if ($user_list[$i] != -1)
{
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . intval($user_list[$i]);
}
}
}
for ($i = 0; $i < count($user_list); $i++) {
if ($user_list[$i] != -1) {
$where_sql .= (($where_sql != '') ? ', ' : '') . intval($user_list[$i]);
}
}
}
if (isset($_POST['unban_ip']))
{
$ip_list = $_POST['unban_ip'];
if (isset($_POST['unban_ip'])) {
$ip_list = $_POST['unban_ip'];
for ($i = 0; $i < count($ip_list); $i++)
{
if ($ip_list[$i] != -1)
{
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . DB()->escape($ip_list[$i]);
}
}
}
for ($i = 0; $i < count($ip_list); $i++) {
if ($ip_list[$i] != -1) {
$where_sql .= (($where_sql != '') ? ', ' : '') . DB()->escape($ip_list[$i]);
}
}
}
if (isset($_POST['unban_email']))
{
$email_list = $_POST['unban_email'];
if (isset($_POST['unban_email'])) {
$email_list = $_POST['unban_email'];
for ($i = 0; $i < count($email_list); $i++)
{
if ($email_list[$i] != -1)
{
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . DB()->escape($email_list[$i]);
}
}
}
for ($i = 0; $i < count($email_list); $i++) {
if ($email_list[$i] != -1) {
$where_sql .= (($where_sql != '') ? ', ' : '') . DB()->escape($email_list[$i]);
}
}
}
if ($where_sql != '')
{
$sql = "DELETE FROM " . BB_BANLIST . " WHERE ban_id IN ($where_sql)";
if (!DB()->sql_query($sql))
{
bb_die('Could not delete ban info from database');
}
}
if ($where_sql != '') {
$sql = "DELETE FROM " . BB_BANLIST . " WHERE ban_id IN ($where_sql)";
if (!DB()->sql_query($sql)) {
bb_die('Could not delete ban info from database');
}
}
bb_die($lang['BAN_UPDATE_SUCESSFUL'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_BANADMIN'], '<a href="admin_user_ban.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
else
{
$template->assign_vars(array(
'S_BANLIST_ACTION' => 'admin_user_ban.php',
));
bb_die($lang['BAN_UPDATE_SUCESSFUL'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_BANADMIN'], '<a href="admin_user_ban.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} else {
$template->assign_vars(array(
'S_BANLIST_ACTION' => 'admin_user_ban.php',
));
$userban_count = 0;
$ipban_count = 0;
$emailban_count = 0;
$userban_count = 0;
$ipban_count = 0;
$emailban_count = 0;
$sql = "SELECT b.ban_id, u.user_id, u.username
$sql = "SELECT b.ban_id, u.user_id, u.username
FROM " . BB_BANLIST . " b, " . BB_USERS . " u
WHERE u.user_id = b.ban_userid
AND b.ban_userid <> 0
AND u.user_id <> " . GUEST_UID . "
ORDER BY u.username ASC";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not select current user_id ban list');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select current user_id ban list');
}
$user_list = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
$user_list = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
$select_userlist = '';
for ($i = 0; $i < count($user_list); $i++)
{
$select_userlist .= '<option value="' . $user_list[$i]['ban_id'] . '">' . $user_list[$i]['username'] . '</option>';
$userban_count++;
}
$select_userlist = '';
for ($i = 0; $i < count($user_list); $i++) {
$select_userlist .= '<option value="' . $user_list[$i]['ban_id'] . '">' . $user_list[$i]['username'] . '</option>';
$userban_count++;
}
if ($select_userlist == '')
{
$select_userlist = '<option value="-1">' . $lang['NO_BANNED_USERS'] . '</option>';
}
if ($select_userlist == '') {
$select_userlist = '<option value="-1">' . $lang['NO_BANNED_USERS'] . '</option>';
}
$select_userlist = '<select name="unban_user[]" multiple="multiple" size="5">' . $select_userlist . '</select>';
$select_userlist = '<select name="unban_user[]" multiple="multiple" size="5">' . $select_userlist . '</select>';
$sql = "SELECT ban_id, ban_ip, ban_email FROM ". BB_BANLIST ." ORDER BY ban_ip";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not select current ip ban list');
}
$sql = "SELECT ban_id, ban_ip, ban_email FROM " . BB_BANLIST . " ORDER BY ban_ip";
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select current ip ban list');
}
$banlist = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
$banlist = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
$select_iplist = '';
$select_emaillist = '';
$select_iplist = '';
$select_emaillist = '';
for ($i = 0; $i < count($banlist); $i++)
{
$ban_id = $banlist[$i]['ban_id'];
for ($i = 0; $i < count($banlist); $i++) {
$ban_id = $banlist[$i]['ban_id'];
if (!empty($banlist[$i]['ban_ip']))
{
$ban_ip = str_replace('255', '*', decode_ip($banlist[$i]['ban_ip']));
$select_iplist .= '<option value="' . $ban_id . '">' . $ban_ip . '</option>';
$ipban_count++;
}
else if (!empty($banlist[$i]['ban_email']))
{
$ban_email = $banlist[$i]['ban_email'];
$select_emaillist .= '<option value="' . $ban_id . '">' . $ban_email . '</option>';
$emailban_count++;
}
}
if (!empty($banlist[$i]['ban_ip'])) {
$ban_ip = str_replace('255', '*', decode_ip($banlist[$i]['ban_ip']));
$select_iplist .= '<option value="' . $ban_id . '">' . $ban_ip . '</option>';
$ipban_count++;
} elseif (!empty($banlist[$i]['ban_email'])) {
$ban_email = $banlist[$i]['ban_email'];
$select_emaillist .= '<option value="' . $ban_id . '">' . $ban_email . '</option>';
$emailban_count++;
}
}
if ($select_iplist == '')
{
$select_iplist = '<option value="-1">' . $lang['NO_BANNED_IP'] . '</option>';
}
if ($select_iplist == '') {
$select_iplist = '<option value="-1">' . $lang['NO_BANNED_IP'] . '</option>';
}
if ($select_emaillist == '')
{
$select_emaillist = '<option value="-1">' . $lang['NO_BANNED_EMAIL'] . '</option>';
}
if ($select_emaillist == '') {
$select_emaillist = '<option value="-1">' . $lang['NO_BANNED_EMAIL'] . '</option>';
}
$select_iplist = '<select name="unban_ip[]" multiple="multiple" size="15">' . $select_iplist . '</select>';
$select_emaillist = '<select name="unban_email[]" multiple="multiple" size="10">' . $select_emaillist . '</select>';
$select_iplist = '<select name="unban_ip[]" multiple="multiple" size="15">' . $select_iplist . '</select>';
$select_emaillist = '<select name="unban_email[]" multiple="multiple" size="10">' . $select_emaillist . '</select>';
$template->assign_vars(array(
'U_SEARCH_USER' => './../search.php?mode=searchuser',
'S_UNBAN_USERLIST_SELECT' => $select_userlist,
'S_UNBAN_IPLIST_SELECT' => $select_iplist,
'S_UNBAN_EMAILLIST_SELECT' => $select_emaillist,
'S_BAN_ACTION' => 'admin_user_ban.php',
));
$template->assign_vars(array(
'U_SEARCH_USER' => './../search.php?mode=searchuser',
'S_UNBAN_USERLIST_SELECT' => $select_userlist,
'S_UNBAN_IPLIST_SELECT' => $select_iplist,
'S_UNBAN_EMAILLIST_SELECT' => $select_emaillist,
'S_BAN_ACTION' => 'admin_user_ban.php',
));
}
print_page('admin_user_ban.tpl', 'admin');
print_page('admin_user_ban.tpl', 'admin');

File diff suppressed because it is too large Load diff

View file

@ -1,157 +1,151 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!empty($setmodules))
{
$module['GENERAL']['WORD_CENSOR'] = basename(__FILE__);
return;
if (!empty($setmodules)) {
$module['GENERAL']['WORD_CENSOR'] = basename(__FILE__);
return;
}
require('./pagestart.php');
if (!$bb_cfg['use_word_censor'])
{
bb_die('Word censor disabled <br /><br /> ($bb_cfg[\'use_word_censor\'] in config.php)');
if (!$bb_cfg['use_word_censor']) {
bb_die('Word censor disabled <br /><br /> ($bb_cfg[\'use_word_censor\'] in config.php)');
}
$mode = request_var('mode', '');
$mode = htmlspecialchars($mode);
if (isset($_POST['add']))
{
$mode = 'add';
}
else if (isset($_POST['save']))
{
$mode = 'save';
if (isset($_POST['add'])) {
$mode = 'add';
} elseif (isset($_POST['save'])) {
$mode = 'save';
}
if ($mode != '')
{
if ($mode == 'edit' || $mode == 'add')
{
$word_id = intval(request_var('id', 0));
if ($mode != '') {
if ($mode == 'edit' || $mode == 'add') {
$word_id = intval(request_var('id', 0));
$s_hidden_fields = $word = $replacement = '';
$s_hidden_fields = $word = $replacement = '';
if ($mode == 'edit')
{
if ($word_id)
{
$sql = "SELECT * FROM " . BB_WORDS . " WHERE word_id = $word_id";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not query words table #1');
}
if ($mode == 'edit') {
if ($word_id) {
$sql = "SELECT * FROM " . BB_WORDS . " WHERE word_id = $word_id";
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query words table #1');
}
$word_info = DB()->sql_fetchrow($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
$word = $word_info['word'];
$replacement = $word_info['replacement'];
}
else
{
bb_die($lang['NO_WORD_SELECTED']);
}
}
$word_info = DB()->sql_fetchrow($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
$word = $word_info['word'];
$replacement = $word_info['replacement'];
} else {
bb_die($lang['NO_WORD_SELECTED']);
}
}
$template->assign_vars(array(
'TPL_ADMIN_WORDS_EDIT' => true,
'WORD' => $word,
'REPLACEMENT' => $replacement,
'S_WORDS_ACTION' => 'admin_words.php',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else if ($mode == 'save')
{
$word_id = intval(request_var('id', 0));
$word = trim(request_var('word', ''));
$replacement = trim(request_var('replacement', ''));
$template->assign_vars(array(
'TPL_ADMIN_WORDS_EDIT' => true,
'WORD' => $word,
'REPLACEMENT' => $replacement,
'S_WORDS_ACTION' => 'admin_words.php',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
} elseif ($mode == 'save') {
$word_id = intval(request_var('id', 0));
$word = trim(request_var('word', ''));
$replacement = trim(request_var('replacement', ''));
if ($word == '' || $replacement == '')
{
bb_die($lang['MUST_ENTER_WORD']);
}
if ($word == '' || $replacement == '') {
bb_die($lang['MUST_ENTER_WORD']);
}
if ($word_id)
{
$sql = "UPDATE " . BB_WORDS . "
if ($word_id) {
$sql = "UPDATE " . BB_WORDS . "
SET word = '" . DB()->escape($word) . "', replacement = '" . DB()->escape($replacement) . "'
WHERE word_id = $word_id";
$message = $lang['WORD_UPDATED'];
}
else
{
$sql = "INSERT INTO " . BB_WORDS . " (word, replacement)
$message = $lang['WORD_UPDATED'];
} else {
$sql = "INSERT INTO " . BB_WORDS . " (word, replacement)
VALUES ('" . DB()->escape($word) . "', '" . DB()->escape($replacement) . "')";
$message = $lang['WORD_ADDED'];
}
$message = $lang['WORD_ADDED'];
}
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not insert data into words table');
}
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not insert data into words table');
}
CACHE('bb_cache')->rm('censored');
$message .= '<br /><br />' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '<a href="admin_words.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
CACHE('bb_cache')->rm('censored');
$message .= '<br /><br />' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '<a href="admin_words.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
else if ($mode == 'delete')
{
$word_id = intval(request_var('id', 0));
bb_die($message);
} elseif ($mode == 'delete') {
$word_id = intval(request_var('id', 0));
if ($word_id)
{
$sql = "DELETE FROM " . BB_WORDS . " WHERE word_id = $word_id";
if ($word_id) {
$sql = "DELETE FROM " . BB_WORDS . " WHERE word_id = $word_id";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not remove data from words table');
}
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not remove data from words table');
}
CACHE('bb_cache')->rm('censored');
CACHE('bb_cache')->rm('censored');
bb_die($lang['WORD_REMOVED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '<a href="admin_words.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
else
{
bb_die($lang['NO_WORD_SELECTED']);
}
}
}
else
{
$sql = "SELECT * FROM " . BB_WORDS . " ORDER BY word";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not query words table #2');
}
bb_die($lang['WORD_REMOVED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_WORDADMIN'], '<a href="admin_words.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
} else {
bb_die($lang['NO_WORD_SELECTED']);
}
}
} else {
$sql = "SELECT * FROM " . BB_WORDS . " ORDER BY word";
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query words table #2');
}
$word_rows = DB()->sql_fetchrowset($result);
$word_count = count($word_rows);
$word_rows = DB()->sql_fetchrowset($result);
$word_count = count($word_rows);
$template->assign_vars(array(
'TPL_ADMIN_WORDS_LIST' => true,
'S_WORDS_ACTION' => 'admin_words.php',
'S_HIDDEN_FIELDS' => '',
));
$template->assign_vars(array(
'TPL_ADMIN_WORDS_LIST' => true,
'S_WORDS_ACTION' => 'admin_words.php',
'S_HIDDEN_FIELDS' => '',
));
for ($i = 0; $i < $word_count; $i++)
{
$word = $word_rows[$i]['word'];
$replacement = $word_rows[$i]['replacement'];
$word_id = $word_rows[$i]['word_id'];
for ($i = 0; $i < $word_count; $i++) {
$word = $word_rows[$i]['word'];
$replacement = $word_rows[$i]['replacement'];
$word_id = $word_rows[$i]['word_id'];
$row_class = !($i % 2) ? 'row1' : 'row2';
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('words', array(
'ROW_CLASS' => $row_class,
'WORD' => $word,
'REPLACEMENT' => $replacement,
'U_WORD_EDIT' => "admin_words.php?mode=edit&amp;id=$word_id",
'U_WORD_DELETE' => "admin_words.php?mode=delete&amp;id=$word_id",
));
}
$template->assign_block_vars('words', array(
'ROW_CLASS' => $row_class,
'WORD' => $word,
'REPLACEMENT' => $replacement,
'U_WORD_EDIT' => "admin_words.php?mode=edit&amp;id=$word_id",
'U_WORD_DELETE' => "admin_words.php?mode=delete&amp;id=$word_id",
));
}
}
print_page('admin_words.tpl', 'admin');
print_page('admin_words.tpl', 'admin');

View file

@ -1,292 +1,272 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
require('./pagestart.php');
// Generate relevant output
if (isset($_GET['pane']) && $_GET['pane'] == 'left')
{
if (!$module = CACHE('bb_cache')->get('admin_module'))
{
$dir = @opendir('.');
$setmodules = 1;
while ($file = @readdir($dir))
{
if (preg_match('/^admin_.*?\.php$/', $file))
{
include('./' . $file);
}
}
unset($setmodules);
@closedir($dir);
CACHE('bb_cache')->set('admin_module', $module, 600);
}
if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
if (!$module = CACHE('bb_cache')->get('admin_module')) {
$dir = @opendir('.');
$setmodules = 1;
while ($file = @readdir($dir)) {
if (preg_match('/^admin_.*?\.php$/', $file)) {
include('./' . $file);
}
}
unset($setmodules);
@closedir($dir);
CACHE('bb_cache')->set('admin_module', $module, 600);
}
$template->assign_vars(array(
'TPL_ADMIN_NAVIGATE' => true,
'U_FORUM_INDEX' => '../index.php',
'U_ADMIN_INDEX' => 'index.php?pane=right',
));
$template->assign_vars(array(
'TPL_ADMIN_NAVIGATE' => true,
'U_FORUM_INDEX' => '../index.php',
'U_ADMIN_INDEX' => 'index.php?pane=right',
));
ksort($module);
ksort($module);
while (list($cat, $action_array) = each($module))
{
$cat = (!empty($lang[$cat])) ? $lang[$cat] : preg_replace('/_/', ' ', $cat);
while (list($cat, $action_array) = each($module)) {
$cat = (!empty($lang[$cat])) ? $lang[$cat] : preg_replace('/_/', ' ', $cat);
$template->assign_block_vars('catrow', array(
'ADMIN_CATEGORY' => $cat,
));
$template->assign_block_vars('catrow', array(
'ADMIN_CATEGORY' => $cat,
));
ksort($action_array);
ksort($action_array);
$row_count = 0;
while (list($action, $file) = each($action_array))
{
$row_class = !($row_count % 2) ? 'row1' : 'row2';
$row_count = 0;
while (list($action, $file) = each($action_array)) {
$row_class = !($row_count % 2) ? 'row1' : 'row2';
$action = (!empty($lang[$action])) ? $lang[$action] : preg_replace('/_/', ' ', $action);
$action = (!empty($lang[$action])) ? $lang[$action] : preg_replace('/_/', ' ', $action);
$template->assign_block_vars('catrow.modulerow', array(
'ROW_CLASS' => $row_class,
'ADMIN_MODULE' => $action,
'U_ADMIN_MODULE' => $file,
));
$row_count++;
}
}
}
elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
{
$template->assign_vars(array(
'TPL_ADMIN_MAIN' => true,
'ADMIN_LOCK' => ($bb_cfg['board_disable']) ? true : false,
'ADMIN_LOCK_CRON' => (file_exists(BB_DISABLED)) ? true :false,
));
$template->assign_block_vars('catrow.modulerow', array(
'ROW_CLASS' => $row_class,
'ADMIN_MODULE' => $action,
'U_ADMIN_MODULE' => $file,
));
$row_count++;
}
}
} elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') {
$template->assign_vars(array(
'TPL_ADMIN_MAIN' => true,
'ADMIN_LOCK' => ($bb_cfg['board_disable']) ? true : false,
'ADMIN_LOCK_CRON' => (file_exists(BB_DISABLED)) ? true : false,
));
// Get forum statistics
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$total_topics = get_db_stat('topiccount');
$start_date = bb_date($bb_cfg['board_startdate']);
$boarddays = (TIMENOW - $bb_cfg['board_startdate']) / 86400;
// Get forum statistics
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$total_topics = get_db_stat('topiccount');
$start_date = bb_date($bb_cfg['board_startdate']);
$boarddays = (TIMENOW - $bb_cfg['board_startdate']) / 86400;
$posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
$topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
$users_per_day = sprintf('%.2f', $total_users / $boarddays);
$posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
$topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
$users_per_day = sprintf('%.2f', $total_users / $boarddays);
$avatar_dir_size = 0;
$avatar_dir_size = 0;
if ($avatar_dir = @opendir(BB_ROOT . $bb_cfg['avatar_path']))
{
while( $file = @readdir($avatar_dir) )
{
if( $file != '.' && $file != '..' )
{
$avatar_dir_size += @filesize(BB_ROOT . $bb_cfg['avatar_path'] . '/' . $file);
}
}
@closedir($avatar_dir);
if ($avatar_dir = @opendir(BB_ROOT . $bb_cfg['avatar_path'])) {
while ($file = @readdir($avatar_dir)) {
if ($file != '.' && $file != '..') {
$avatar_dir_size += @filesize(BB_ROOT . $bb_cfg['avatar_path'] . '/' . $file);
}
}
@closedir($avatar_dir);
$avatar_dir_size = humn_size($avatar_dir_size);
}
else
{
$avatar_dir_size = $lang['NOT_AVAILABLE'];
}
$avatar_dir_size = humn_size($avatar_dir_size);
} else {
$avatar_dir_size = $lang['NOT_AVAILABLE'];
}
if (intval($posts_per_day) > $total_posts)
{
$posts_per_day = $total_posts;
}
if (intval($posts_per_day) > $total_posts) {
$posts_per_day = $total_posts;
}
if (intval($topics_per_day) > $total_topics)
{
$topics_per_day = $total_topics;
}
if (intval($topics_per_day) > $total_topics) {
$topics_per_day = $total_topics;
}
if ($users_per_day > $total_users)
{
$users_per_day = $total_users;
}
if ($users_per_day > $total_users) {
$users_per_day = $total_users;
}
// DB size ... MySQL only
$sql = "SELECT VERSION() AS mysql_version";
if ($result = DB()->sql_query($sql))
{
$row = DB()->sql_fetchrow($result);
$version = $row['mysql_version'];
// DB size ... MySQL only
$sql = "SELECT VERSION() AS mysql_version";
if ($result = DB()->sql_query($sql)) {
$row = DB()->sql_fetchrow($result);
$version = $row['mysql_version'];
if (preg_match('/^(3\.23|4\.|5\.|10\.)/', $version))
{
$dblist = array();
foreach ($bb_cfg['db'] as $name => $row)
{
$sql = "SHOW TABLE STATUS FROM {$row[1]}";
if ($result = DB()->sql_query($sql))
{
$tabledata_ary = DB()->sql_fetchrowset($result);
if (preg_match('/^(3\.23|4\.|5\.|10\.)/', $version)) {
$dblist = array();
foreach ($bb_cfg['db'] as $name => $row) {
$sql = "SHOW TABLE STATUS FROM {$row[1]}";
if ($result = DB()->sql_query($sql)) {
$tabledata_ary = DB()->sql_fetchrowset($result);
$dbsize = 0;
for ($i = 0; $i < count($tabledata_ary); $i++)
{
if( @$tabledata_ary[$i]['Type'] != 'MRG_MYISAM' )
{
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
}
}
$dblist[] = '<span title="'. $name .'">'. humn_size($dbsize) .'</span>';
}
}
$dbsize = implode('&nbsp;|&nbsp;', $dblist);
}
else
{
$dbsize = $lang['NOT_AVAILABLE'];
}
}
else
{
$dbsize = $lang['NOT_AVAILABLE'];
}
$dbsize = 0;
for ($i = 0; $i < count($tabledata_ary); $i++) {
if (@$tabledata_ary[$i]['Type'] != 'MRG_MYISAM') {
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
}
}
$dblist[] = '<span title="' . $name . '">' . humn_size($dbsize) . '</span>';
}
}
$dbsize = implode('&nbsp;|&nbsp;', $dblist);
} else {
$dbsize = $lang['NOT_AVAILABLE'];
}
} else {
$dbsize = $lang['NOT_AVAILABLE'];
}
$template->assign_vars(array(
'NUMBER_OF_POSTS' => $total_posts,
'NUMBER_OF_TOPICS' => $total_topics,
'NUMBER_OF_USERS' => $total_users,
'START_DATE' => $start_date,
'POSTS_PER_DAY' => $posts_per_day,
'TOPICS_PER_DAY' => $topics_per_day,
'USERS_PER_DAY' => $users_per_day,
'AVATAR_DIR_SIZE' => $avatar_dir_size,
'DB_SIZE' => $dbsize,
'GZIP_COMPRESSION' => ($bb_cfg['gzip_compress']) ? $lang['ON'] : $lang['OFF'],
));
$template->assign_vars(array(
'NUMBER_OF_POSTS' => $total_posts,
'NUMBER_OF_TOPICS' => $total_topics,
'NUMBER_OF_USERS' => $total_users,
'START_DATE' => $start_date,
'POSTS_PER_DAY' => $posts_per_day,
'TOPICS_PER_DAY' => $topics_per_day,
'USERS_PER_DAY' => $users_per_day,
'AVATAR_DIR_SIZE' => $avatar_dir_size,
'DB_SIZE' => $dbsize,
'GZIP_COMPRESSION' => ($bb_cfg['gzip_compress']) ? $lang['ON'] : $lang['OFF'],
));
if (@$_GET['users_online'])
{
$template->assign_vars(array(
'SHOW_USERS_ONLINE' => true,
));
if (@$_GET['users_online']) {
$template->assign_vars(array(
'SHOW_USERS_ONLINE' => true,
));
// Get users online information.
$sql = "SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start
// Get users online information.
$sql = "SELECT u.user_id, u.username, u.user_rank, s.session_time AS user_session_time, u.user_opt, s.session_logged_in, s.session_ip, s.session_start
FROM " . BB_USERS . " u, " . BB_SESSIONS . " s
WHERE s.session_logged_in = 1
AND u.user_id = s.session_user_id
AND u.user_id <> " . GUEST_UID . "
AND s.session_time >= " . ( TIMENOW - 300 ) . "
AND s.session_time >= " . (TIMENOW - 300) . "
ORDER BY s.session_ip ASC, s.session_time DESC";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not obtain reged user / online information');
}
$onlinerow_reg = DB()->sql_fetchrowset($result);
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain reged user / online information');
}
$onlinerow_reg = DB()->sql_fetchrowset($result);
$sql = "SELECT session_logged_in, session_time, session_ip, session_start
$sql = "SELECT session_logged_in, session_time, session_ip, session_start
FROM " . BB_SESSIONS . "
WHERE session_logged_in = 0
AND session_time >= " . ( TIMENOW - 300 ) . "
AND session_time >= " . (TIMENOW - 300) . "
ORDER BY session_ip ASC, session_time DESC";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not obtain guest user / online information');
}
$onlinerow_guest = DB()->sql_fetchrowset($result);
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain guest user / online information');
}
$onlinerow_guest = DB()->sql_fetchrowset($result);
$reg_userid_ary = array();
$reg_userid_ary = array();
if (count($onlinerow_reg))
{
$registered_users = $hidden_users = 0;
if (count($onlinerow_reg)) {
$registered_users = $hidden_users = 0;
for ($i = 0, $cnt = count($onlinerow_reg); $i < $cnt; $i++)
{
if (!in_array($onlinerow_reg[$i]['user_id'], $reg_userid_ary))
{
$reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
for ($i = 0, $cnt = count($onlinerow_reg); $i < $cnt; $i++) {
if (!in_array($onlinerow_reg[$i]['user_id'], $reg_userid_ary)) {
$reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
$username = $onlinerow_reg[$i]['username'];
$username = $onlinerow_reg[$i]['username'];
if (bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline'))
{
$hidden_users++;
$hidden = TRUE;
}
else
{
$registered_users++;
$hidden = FALSE;
}
if (bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline')) {
$hidden_users++;
$hidden = true;
} else {
$registered_users++;
$hidden = false;
}
$row_class = 'row1';
$row_class = 'row1';
$reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
$reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
$template->assign_block_vars('reg_user_row', array(
'ROW_CLASS' => $row_class,
'USER' => profile_url($onlinerow_reg[$i]),
'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', false),
'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', false),
'IP_ADDRESS' => $reg_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $reg_ip,
));
}
}
}
$template->assign_block_vars('reg_user_row', array(
'ROW_CLASS' => $row_class,
'USER' => profile_url($onlinerow_reg[$i]),
'STARTED' => bb_date($onlinerow_reg[$i]['session_start'], 'H:i', false),
'LASTUPDATE' => bb_date($onlinerow_reg[$i]['user_session_time'], 'H:i', false),
'IP_ADDRESS' => $reg_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $reg_ip,
));
}
}
}
// Guest users
if (count($onlinerow_guest))
{
$guest_users = 0;
// Guest users
if (count($onlinerow_guest)) {
$guest_users = 0;
for ($i = 0; $i < count($onlinerow_guest); $i++)
{
$guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
$guest_users++;
for ($i = 0; $i < count($onlinerow_guest); $i++) {
$guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
$guest_users++;
$row_class = 'row2';
$row_class = 'row2';
$guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
$guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
$template->assign_block_vars('guest_user_row', array(
'ROW_CLASS' => $row_class,
'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', false),
'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'H:i' , false),
'IP_ADDRESS' => $guest_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $guest_ip,
));
}
}
}
else
{
$template->assign_vars(array(
'USERS_ONLINE_HREF' => 'index.php?pane=right&users_online=1',
));
}
}
else
{
// Generate frameset
$template->assign_vars(array(
'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'],
'TPL_ADMIN_FRAMESET' => true,
));
send_no_cache_headers();
print_page('index.tpl', 'admin', 'no_header');
$template->assign_block_vars('guest_user_row', array(
'ROW_CLASS' => $row_class,
'STARTED' => bb_date($onlinerow_guest[$i]['session_start'], 'H:i', false),
'LASTUPDATE' => bb_date($onlinerow_guest[$i]['session_time'], 'H:i', false),
'IP_ADDRESS' => $guest_ip,
'U_WHOIS_IP' => $bb_cfg['whois_info'] . $guest_ip,
));
}
}
} else {
$template->assign_vars(array(
'USERS_ONLINE_HREF' => 'index.php?pane=right&users_online=1',
));
}
} else {
// Generate frameset
$template->assign_vars(array(
'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'],
'TPL_ADMIN_FRAMESET' => true,
));
send_no_cache_headers();
print_page('index.tpl', 'admin', 'no_header');
}
print_page('index.tpl', 'admin');
// Functions
function inarray ($needle, $haystack)
function inarray($needle, $haystack)
{
for ($i = 0; $i < sizeof($haystack); $i++)
{
if ($haystack[$i] == $needle)
{
return true;
}
}
return false;
}
for ($i = 0; $i < sizeof($haystack); $i++) {
if ($haystack[$i] == $needle) {
return true;
}
}
return false;
}

View file

@ -1,28 +1,48 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('BB_ROOT', './../');
define('IN_FORUM', true);
define('IN_ADMIN', true);
require(BB_ROOT .'common.php');
require(ATTACH_DIR .'attachment_mod.php');
require(ATTACH_DIR .'includes/functions_admin.php');
require_once(INC_DIR .'functions_admin.php');
require(BB_ROOT . 'common.php');
require(ATTACH_DIR . 'attachment_mod.php');
require(ATTACH_DIR . 'includes/functions_admin.php');
require_once(INC_DIR . 'functions_admin.php');
$user->session_start();
if (IS_GUEST)
{
redirect(LOGIN_URL . "?redirect=admin/index.php");
if (IS_GUEST) {
redirect(LOGIN_URL . "?redirect=admin/index.php");
}
if (!IS_ADMIN)
{
bb_die($lang['NOT_ADMIN']);
if (!IS_ADMIN) {
bb_die($lang['NOT_ADMIN']);
}
if (!$userdata['session_admin'])
{
$redirect = url_arg($_SERVER['REQUEST_URI'], 'admin', 1);
redirect("login.php?redirect=$redirect");
}
if (!$userdata['session_admin']) {
$redirect = url_arg($_SERVER['REQUEST_URI'], 'admin', 1);
redirect("login.php?redirect=$redirect");
}

View file

@ -1,48 +1,70 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_ADMIN', true);
define('BB_ROOT', './../../');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
$user->session_start();
if (!IS_ADMIN) bb_die($lang['NOT_AUTHORISED']);
if (!IS_ADMIN) {
bb_die($lang['NOT_AUTHORISED']);
}
$sql[] = 'SELECT count(*) FROM `'.BB_USERS.'` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-2592000';
$sql[] = 'SELECT count(*) FROM `'.BB_USERS.'` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-7776000';
$sql[] = 'SELECT round(avg(size)/1048576) FROM `'.BB_BT_TORRENTS.'`';
$sql[] = 'SELECT count(*) FROM `'.BB_BT_TORRENTS.'`';
$sql[] = 'SELECT count(distinct(topic_id)) FROM `'.BB_BT_TRACKER_SNAP.'` WHERE seeders > 0';
$sql[] = 'SELECT count(distinct(topic_id)) FROM `'.BB_BT_TRACKER_SNAP.'` WHERE seeders > 5';
$sql[] = 'SELECT count(distinct(poster_id)) FROM `'.BB_BT_TORRENTS.'`';
$sql[] = 'SELECT count(distinct(poster_id)) FROM `'.BB_BT_TORRENTS.'` WHERE reg_time >= UNIX_TIMESTAMP()-2592000';
$sql[] = 'SELECT count(*) FROM `' . BB_USERS . '` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-2592000';
$sql[] = 'SELECT count(*) FROM `' . BB_USERS . '` WHERE `user_lastvisit` < UNIX_TIMESTAMP()-7776000';
$sql[] = 'SELECT round(avg(size)/1048576) FROM `' . BB_BT_TORRENTS . '`';
$sql[] = 'SELECT count(*) FROM `' . BB_BT_TORRENTS . '`';
$sql[] = 'SELECT count(distinct(topic_id)) FROM `' . BB_BT_TRACKER_SNAP . '` WHERE seeders > 0';
$sql[] = 'SELECT count(distinct(topic_id)) FROM `' . BB_BT_TRACKER_SNAP . '` WHERE seeders > 5';
$sql[] = 'SELECT count(distinct(poster_id)) FROM `' . BB_BT_TORRENTS . '`';
$sql[] = 'SELECT count(distinct(poster_id)) FROM `' . BB_BT_TORRENTS . '` WHERE reg_time >= UNIX_TIMESTAMP()-2592000';
echo '<html><body><head></head>';
echo '
<br /><br />
<table border="1" cellspacing="0" cellpadding="6" align="center">';
foreach ($sql as $i => $query)
{
$row = mysqli_fetch_row(DB()->query($query));
echo "<tr><td>{$lang['TR_STATS'][$i]}</td><td><b>{$row[0]}</b></td>";
foreach ($sql as $i => $query) {
$row = mysqli_fetch_row(DB()->query($query));
echo "<tr><td>{$lang['TR_STATS'][$i]}</td><td><b>{$row[0]}</b></td>";
}
echo '</table>';
echo '<div align="center"><pre>';
if ($l = sys('la'))
{
$l = explode(' ', $l);
for ($i=0; $i < 3; $i++)
{
$l[$i] = round($l[$i], 1);
}
echo "\n\n<b>loadavg: </b>$l[0] $l[1] $l[2]\n\n";
if ($l = sys('la')) {
$l = explode(' ', $l);
for ($i = 0; $i < 3; $i++) {
$l[$i] = round($l[$i], 1);
}
echo "\n\n<b>loadavg: </b>$l[0] $l[1] $l[2]\n\n";
}
echo 'gen time: <b>'. sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) ."</b> sec\n";
echo 'gen time: <b>' . sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) . "</b> sec\n";
echo '</pre></div>';
echo '</body></html>';

View file

@ -1,12 +1,37 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_ADMIN', true);
define('BB_ROOT', './../../');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
$user->session_start();
if (!IS_ADMIN) bb_die($lang['NOT_AUTHORISED']);
if (!IS_ADMIN) {
bb_die($lang['NOT_AUTHORISED']);
}
$peers_in_last_minutes = array(30, 15, 5, 1);
$peers_in_last_sec_limit = 300;
@ -17,7 +42,7 @@ $stat = array();
define('TMP_TRACKER_TABLE', 'tmp_tracker');
DB()->query("
CREATE TEMPORARY TABLE ". TMP_TRACKER_TABLE ." (
CREATE TEMPORARY TABLE " . TMP_TRACKER_TABLE . " (
`topic_id` mediumint(8) unsigned NOT NULL default '0',
`user_id` mediumint(9) NOT NULL default '0',
`ip` char(8) binary NOT NULL default '0',
@ -28,53 +53,53 @@ DB()->query("
)
SELECT
topic_id, user_id, ip, seeder, speed_up, speed_down, update_time
FROM ". BB_BT_TRACKER ."
FROM " . BB_BT_TRACKER . "
");
// Peers within announce interval
$stat += DB()->fetch_row("SELECT COUNT(*) AS p_within_ann FROM ". TMP_TRACKER_TABLE ." WHERE update_time >= ". (TIMENOW - $announce_interval));
$stat += DB()->fetch_row("SELECT COUNT(*) AS p_within_ann FROM " . TMP_TRACKER_TABLE . " WHERE update_time >= " . (TIMENOW - $announce_interval));
// All peers, "max_peer_time"
$stat += DB()->fetch_row("SELECT COUNT(*) AS p_all, SUM(speed_up) as speed_up, SUM(speed_down) as speed_down, UNIX_TIMESTAMP() - MIN(update_time) AS max_peer_time, UNIX_TIMESTAMP() - MAX(update_time) AS last_peer_time FROM ". TMP_TRACKER_TABLE);
$stat += DB()->fetch_row("SELECT COUNT(*) AS p_all, SUM(speed_up) as speed_up, SUM(speed_down) as speed_down, UNIX_TIMESTAMP() - MIN(update_time) AS max_peer_time, UNIX_TIMESTAMP() - MAX(update_time) AS last_peer_time FROM " . TMP_TRACKER_TABLE);
// Active users
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT user_id) AS u_bt_active FROM ". TMP_TRACKER_TABLE);
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT user_id) AS u_bt_active FROM " . TMP_TRACKER_TABLE);
// All bt-users
$stat += DB()->fetch_row("SELECT COUNT(*) AS u_bt_all FROM ". BB_BT_USERS);
$stat += DB()->fetch_row("SELECT COUNT(*) AS u_bt_all FROM " . BB_BT_USERS);
// All bb-users
$stat += DB()->fetch_row("SELECT COUNT(*) AS u_bb_all FROM ". BB_USERS);
$stat += DB()->fetch_row("SELECT COUNT(*) AS u_bb_all FROM " . BB_USERS);
// Active torrents
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_active FROM ". TMP_TRACKER_TABLE);
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_active FROM " . TMP_TRACKER_TABLE);
// With seeder
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_with_seeder FROM ". TMP_TRACKER_TABLE ." WHERE seeder = 1");
$stat += DB()->fetch_row("SELECT COUNT(DISTINCT topic_id) AS tor_with_seeder FROM " . TMP_TRACKER_TABLE . " WHERE seeder = 1");
// All torrents
$stat += DB()->fetch_row("SELECT COUNT(*) AS tor_all, SUM(size) AS torrents_size FROM ". BB_BT_TORRENTS);
$stat += DB()->fetch_row("SELECT COUNT(*) AS tor_all, SUM(size) AS torrents_size FROM " . BB_BT_TORRENTS);
// Last xx minutes
$peers_in_last_min = array();
foreach ($peers_in_last_minutes as $t)
{
$row = DB()->fetch_row("
SELECT COUNT(*) AS peers FROM ". TMP_TRACKER_TABLE ." WHERE update_time >= ". (TIMENOW - 60*$t) ."
foreach ($peers_in_last_minutes as $t) {
$row = DB()->fetch_row("
SELECT COUNT(*) AS peers FROM " . TMP_TRACKER_TABLE . " WHERE update_time >= " . (TIMENOW - 60 * $t) . "
");
$peers_in_last_min[$t] = (int) $row['peers'];
$peers_in_last_min[$t] = (int)$row['peers'];
}
// Last xx seconds
$peers_in_last_sec = array();
$rowset = DB()->fetch_rowset("SELECT COUNT(*) AS peers FROM ". TMP_TRACKER_TABLE ." GROUP BY update_time DESC LIMIT $peers_in_last_sec_limit");
foreach ($rowset as $cnt => $row)
{
$peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt%15)) ? " \n" : '');
$rowset = DB()->fetch_rowset("SELECT COUNT(*) AS peers FROM " . TMP_TRACKER_TABLE . " GROUP BY update_time DESC LIMIT $peers_in_last_sec_limit");
foreach ($rowset as $cnt => $row) {
$peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt % 15)) ? " \n" : '');
}
function commify_callback ($matches)
function commify_callback($matches)
{
return commify($matches[0]);
return commify($matches[0]);
}
function commify_ob ($contents)
function commify_ob($contents)
{
return preg_replace_callback("#\b\d+\b#", 'commify_callback', $contents);
return preg_replace_callback("#\b\d+\b#", 'commify_callback', $contents);
}
ob_start('commify_ob');
echo '<html><body><head></head>';
@ -92,7 +117,7 @@ echo "\n
<td align=center>
$stat[tor_all] / <b>$stat[tor_active]</b> / $stat[tor_with_seeder]
&nbsp;
[ ". humn_size($stat['torrents_size']) ." ]
[ " . humn_size($stat['torrents_size']) . " ]
</td></tr>
\n";
@ -101,36 +126,34 @@ echo "\n
<td align=center>
$stat[p_all] / <b>$stat[p_within_ann]</b>
&nbsp;
[ up: ". humn_size($stat['speed_up']) ."/s,
down: ". humn_size($stat['speed_down']) ."/s ]
[ up: " . humn_size($stat['speed_up']) . "/s,
down: " . humn_size($stat['speed_down']) . "/s ]
</td></tr>
\n";
echo "\n<tr><td align=center> peers: in last ". join(' / ', $peers_in_last_minutes) ." min</td>\n";
echo "\n<td align=center>". join(' / ', $peers_in_last_min) ."</td></tr>\n";
echo "\n<tr><td align=center> peers: in last " . join(' / ', $peers_in_last_minutes) . " min</td>\n";
echo "\n<td align=center>" . join(' / ', $peers_in_last_min) . "</td></tr>\n";
echo "\n<tr><td align=center> peers in last $peers_in_last_sec_limit sec <br /> [ per second, DESC order --> ] <br /> last peer: $stat[last_peer_time] seconds ago <br /> ". date("j M H:i:s [T O]") ." </td>\n";
echo '<td align=center style="font-size: 13px; font-family: \'Courier New\',Courier,monospace;"><pre> '. join(' ', $peers_in_last_sec) ."</pre></td></tr>\n";
echo "\n<tr><td align=center> peers in last $peers_in_last_sec_limit sec <br /> [ per second, DESC order --> ] <br /> last peer: $stat[last_peer_time] seconds ago <br /> " . date("j M H:i:s [T O]") . " </td>\n";
echo '<td align=center style="font-size: 13px; font-family: \'Courier New\',Courier,monospace;"><pre> ' . join(' ', $peers_in_last_sec) . "</pre></td></tr>\n";
echo '</table>';
echo '<div align="center"><pre>';
if ($l = sys('la'))
{
$l = explode(' ', $l);
for ($i=0; $i < 3; $i++)
{
$l[$i] = round($l[$i], 1);
}
echo "\n\n<b>loadavg: </b>$l[0] $l[1] $l[2]\n\n";
if ($l = sys('la')) {
$l = explode(' ', $l);
for ($i = 0; $i < 3; $i++) {
$l[$i] = round($l[$i], 1);
}
echo "\n\n<b>loadavg: </b>$l[0] $l[1] $l[2]\n\n";
}
echo 'gen time: <b>'. sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) ."</b> sec\n";
echo 'gen time: <b>' . sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) . "</b> sec\n";
echo '</pre></div>';
echo '</body></html>';
DB()->query("DROP TEMPORARY TABLE ". TMP_TRACKER_TABLE);
DB()->query("DROP TEMPORARY TABLE " . TMP_TRACKER_TABLE);
bb_exit();
bb_exit();

670
ajax.php
View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('BB_SCRIPT', 'ajax');
define('IN_AJAX', true);
@ -13,62 +36,57 @@ $ajax->init();
$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']);
}
else if (file_exists(BB_DISABLED))
{
$ajax->ajax_die($lang['BOARD_DISABLE_CRON']);
}
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;
switch ($ajax->action) {
case 'view_post':
require(INC_DIR . 'bbcode.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 '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 'gen_passkey':
require(ATTACH_DIR . 'attachment_mod.php');
require(INC_DIR . 'functions_torrent.php');
break;
case 'view_torrent':
case 'mod_action':
case 'change_tor_status':
case 'gen_passkey':
require(ATTACH_DIR . 'attachment_mod.php');
require(INC_DIR . 'functions_torrent.php');
break;
case 'change_torrent':
require(ATTACH_DIR . 'attachment_mod.php');
require(INC_DIR . 'functions_torrent.php');
break;
case 'change_torrent':
require(ATTACH_DIR . 'attachment_mod.php');
require(INC_DIR . 'functions_torrent.php');
break;
case 'user_register':
require(INC_DIR . 'functions_validate.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 '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;
case 'group_membership':
case 'manage_group':
require(INC_DIR . 'functions_group.php');
break;
case 'sitemap';
require(CLASS_DIR .'sitemap.php');
break;
case 'sitemap';
require(CLASS_DIR . 'sitemap.php');
break;
}
// Position in $ajax->valid_actions['xxx']
@ -81,348 +99,330 @@ $ajax->exec();
//
class ajax_common
{
var $request = array();
var $response = array();
public $request = array();
public $response = array();
var $valid_actions = array(
// ACTION NAME AJAX_AUTH
'edit_user_profile' => array('admin'),
'change_user_rank' => array('admin'),
'change_user_opt' => array('admin'),
'manage_user' => array('admin'),
'manage_admin' => array('admin'),
'sitemap' => array('admin'),
public $valid_actions = array(
// ACTION NAME AJAX_AUTH
'edit_user_profile' => array('admin'),
'change_user_rank' => array('admin'),
'change_user_opt' => array('admin'),
'manage_user' => array('admin'),
'manage_admin' => array('admin'),
'sitemap' => array('admin'),
'mod_action' => array('mod'),
'topic_tpl' => array('mod'),
'group_membership' => array('mod'),
'post_mod_comment' => array('mod'),
'mod_action' => array('mod'),
'topic_tpl' => array('mod'),
'group_membership' => array('mod'),
'post_mod_comment' => array('mod'),
'avatar' => array('user'),
'gen_passkey' => array('user'),
'change_torrent' => array('user'),
'change_tor_status' => array('user'),
'manage_group' => array('user'),
'avatar' => array('user'),
'gen_passkey' => array('user'),
'change_torrent' => array('user'),
'change_tor_status' => array('user'),
'manage_group' => array('user'),
'view_post' => array('guest'),
'view_torrent' => array('guest'),
'user_register' => array('guest'),
'posts' => array('guest'),
'index_data' => array('guest'),
);
'view_post' => array('guest'),
'view_torrent' => array('guest'),
'user_register' => array('guest'),
'posts' => array('guest'),
'index_data' => array('guest'),
);
var $action = null;
public $action = null;
/**
* Constructor
*/
function ajax_common()
{
ob_start(array(&$this, 'ob_handler'));
header('Content-Type: text/plain');
}
/**
* Constructor
*/
public function ajax_common()
{
ob_start(array(&$this, 'ob_handler'));
header('Content-Type: text/plain');
}
/**
* Perform action
*/
function exec()
{
global $lang;
/**
* Perform action
*/
public function exec()
{
global $lang;
// Exit if we already have errors
if (!empty($this->response['error_code']))
{
$this->send();
}
// Exit if we already have errors
if (!empty($this->response['error_code'])) {
$this->send();
}
// Check that requested action is valid
$action = $this->action;
// 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);
}
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;
// 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;
// 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;
// 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;
// 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;
// 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);
}
default:
trigger_error("invalid auth type for $action", E_USER_ERROR);
}
// Run action
$this->$action();
// Run action
$this->$action();
// Send output
$this->send();
}
// Send output
$this->send();
}
/**
* Exit on error
*/
function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_ERROR)
{
$this->response['error_code'] = $error_code;
$this->response['error_msg'] = $error_msg;
/**
* Exit on error
*/
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();
}
$this->send();
}
/**
* Initialization
*/
function init()
{
$this->request = $_POST;
$this->action =& $this->request['action'];
}
/**
* Initialization
*/
public function init()
{
$this->request = $_POST;
$this->action =& $this->request['action'];
}
/**
* Send data
*/
function send()
{
$this->response['action'] = $this->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();
}
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();
}
// sending output will be handled by $this->ob_handler()
exit();
}
/**
* OB Handler
*/
function ob_handler($contents)
{
if (DBG_USER)
{
if ($contents)
{
$this->response['raw_output'] = $contents;
}
}
/**
* OB Handler
*/
public function ob_handler($contents)
{
if (DBG_USER) {
if ($contents) {
$this->response['raw_output'] = $contents;
}
}
$response_js = Zend\Json\Json::encode($this->response);
$response_js = Zend\Json\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);
}
}
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;
}
return $response_js;
}
/**
* Admin session
*/
function check_admin_session()
{
global $user;
/**
* 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 = array(
'login_username' => $user->data['username'],
'login_password' => $_POST['user_password'],
);
if (!$user->login($login_args, true))
{
$this->ajax_die('Wrong password');
}
}
}
}
if (!$user->data['session_admin']) {
if (empty($this->request['user_password'])) {
$this->prompt_for_password();
} else {
$login_args = array(
'login_username' => $user->data['username'],
'login_password' => $_POST['user_password'],
);
if (!$user->login($login_args, true)) {
$this->ajax_die('Wrong password');
}
}
}
}
/**
* Prompt for password
*/
function prompt_for_password()
{
$this->response['prompt_password'] = 1;
$this->send();
}
/**
* Prompt for password
*/
public function prompt_for_password()
{
$this->response['prompt_password'] = 1;
$this->send();
}
/**
* Prompt for confirmation
*/
function prompt_for_confirm($confirm_msg)
{
if (empty($confirm_msg)) $this->ajax_die('false');
/**
* Prompt for confirmation
*/
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();
}
$this->response['prompt_confirm'] = 1;
$this->response['confirm_msg'] = $confirm_msg;
$this->send();
}
/**
* Verify mod rights
*/
function verify_mod_rights($forum_id)
{
global $userdata, $lang;
/**
* Verify mod rights
*/
public function verify_mod_rights($forum_id)
{
global $userdata, $lang;
$is_auth = auth(AUTH_MOD, $forum_id, $userdata);
$is_auth = auth(AUTH_MOD, $forum_id, $userdata);
if (!$is_auth['auth_mod'])
{
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
}
if (!$is_auth['auth_mod']) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
}
function edit_user_profile()
{
require(AJAX_DIR . 'edit_user_profile.php');
}
public function edit_user_profile()
{
require(AJAX_DIR . 'edit_user_profile.php');
}
function change_user_rank()
{
require(AJAX_DIR . 'change_user_rank.php');
}
public function change_user_rank()
{
require(AJAX_DIR . 'change_user_rank.php');
}
function change_user_opt()
{
require(AJAX_DIR . 'change_user_opt.php');
}
public function change_user_opt()
{
require(AJAX_DIR . 'change_user_opt.php');
}
function gen_passkey()
{
require(AJAX_DIR . 'gen_passkey.php');
}
public function gen_passkey()
{
require(AJAX_DIR . 'gen_passkey.php');
}
function group_membership()
{
require(AJAX_DIR . 'group_membership.php');
}
public function group_membership()
{
require(AJAX_DIR . 'group_membership.php');
}
function manage_group()
{
require(AJAX_DIR . 'edit_group_profile.php');
}
public function manage_group()
{
require(AJAX_DIR . 'edit_group_profile.php');
}
function post_mod_comment()
{
require(AJAX_DIR . 'post_mod_comment.php');
}
public function post_mod_comment()
{
require(AJAX_DIR . 'post_mod_comment.php');
}
function view_post()
{
require(AJAX_DIR . 'view_post.php');
}
public function view_post()
{
require(AJAX_DIR . 'view_post.php');
}
function change_tor_status()
{
require(AJAX_DIR . 'change_tor_status.php');
}
public function change_tor_status()
{
require(AJAX_DIR . 'change_tor_status.php');
}
function change_torrent()
{
require(AJAX_DIR . 'change_torrent.php');
}
public function change_torrent()
{
require(AJAX_DIR . 'change_torrent.php');
}
function view_torrent()
{
require(AJAX_DIR . 'view_torrent.php');
}
public function view_torrent()
{
require(AJAX_DIR . 'view_torrent.php');
}
function user_register()
{
require(AJAX_DIR . 'user_register.php');
}
public function user_register()
{
require(AJAX_DIR . 'user_register.php');
}
function mod_action()
{
require(AJAX_DIR . 'mod_action.php');
}
public function mod_action()
{
require(AJAX_DIR . 'mod_action.php');
}
function posts()
{
require(AJAX_DIR . 'posts.php');
}
public function posts()
{
require(AJAX_DIR . 'posts.php');
}
function manage_user()
{
require(AJAX_DIR . 'manage_user.php');
}
public function manage_user()
{
require(AJAX_DIR . 'manage_user.php');
}
function manage_admin()
{
require(AJAX_DIR . 'manage_admin.php');
}
public function manage_admin()
{
require(AJAX_DIR . 'manage_admin.php');
}
function topic_tpl()
{
require(AJAX_DIR . 'topic_tpl.php');
}
public function topic_tpl()
{
require(AJAX_DIR . 'topic_tpl.php');
}
function index_data()
{
require(AJAX_DIR . 'index_data.php');
}
public function index_data()
{
require(AJAX_DIR . 'index_data.php');
}
function avatar()
{
require(AJAX_DIR . 'avatar.php');
}
public function avatar()
{
require(AJAX_DIR . 'avatar.php');
}
function sitemap()
{
require(AJAX_DIR .'sitemap.php');
}
}
public function sitemap()
{
require(AJAX_DIR . 'sitemap.php');
}
}

View file

@ -1,185 +1,190 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_TRACKER', true);
define('BB_ROOT', './../');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
if (empty($_SERVER['HTTP_USER_AGENT']))
{
header('Location: http://127.0.0.1', true, 301);
die;
if (empty($_SERVER['HTTP_USER_AGENT'])) {
header('Location: http://127.0.0.1', true, 301);
die;
}
// Ignore 'completed' event
if (isset($_GET['event']) && $_GET['event'] === 'completed')
{
if (DBG_LOG) dbg_log(' ', '!die-event-completed');
dummy_exit(mt_rand(600, 1200));
if (isset($_GET['event']) && $_GET['event'] === 'completed') {
if (DBG_LOG) {
dbg_log(' ', '!die-event-completed');
}
dummy_exit(mt_rand(600, 1200));
}
$announce_interval = $bb_cfg['announce_interval'];
$passkey_key = $bb_cfg['passkey_key'];
$max_left_val = 536870912000; // 500 GB
$max_up_down_val = 5497558138880; // 5 TB
$max_up_add_val = 85899345920; // 80 GB
$max_down_add_val = 85899345920; // 80 GB
$max_left_val = 536870912000; // 500 GB
$max_up_down_val = 5497558138880; // 5 TB
$max_up_add_val = 85899345920; // 80 GB
$max_down_add_val = 85899345920; // 80 GB
// Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash']))
{
$_GET['info_hash'] = $_GET['?info_hash'];
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
$_GET['info_hash'] = $_GET['?info_hash'];
}
// Initial request verification
if (strpos($_SERVER['REQUEST_URI'], 'scrape') !== false)
{
msg_die('Please disable SCRAPE!');
if (strpos($_SERVER['REQUEST_URI'], 'scrape') !== false) {
msg_die('Please disable SCRAPE!');
}
if (!isset($_GET[$passkey_key]) || !is_string($_GET[$passkey_key]) || strlen($_GET[$passkey_key]) != BT_AUTH_KEY_LENGTH)
{
msg_die('Please LOG IN and REDOWNLOAD this torrent (passkey not found)');
if (!isset($_GET[$passkey_key]) || !is_string($_GET[$passkey_key]) || strlen($_GET[$passkey_key]) != BT_AUTH_KEY_LENGTH) {
msg_die('Please LOG IN and REDOWNLOAD this torrent (passkey not found)');
}
// Input var names
// String
$input_vars_str = array(
'info_hash',
'peer_id',
'event',
$passkey_key,
'info_hash',
'peer_id',
'event',
$passkey_key,
);
// Numeric
$input_vars_num = array(
'port',
'uploaded',
'downloaded',
'left',
'numwant',
'compact',
'port',
'uploaded',
'downloaded',
'left',
'numwant',
'compact',
);
// Init received data
// String
foreach ($input_vars_str as $var_name)
{
$$var_name = isset($_GET[$var_name]) ? (string) $_GET[$var_name] : null;
foreach ($input_vars_str as $var_name) {
$$var_name = isset($_GET[$var_name]) ? (string)$_GET[$var_name] : null;
}
// Numeric
foreach ($input_vars_num as $var_name)
{
$$var_name = isset($_GET[$var_name]) ? (float) $_GET[$var_name] : null;
foreach ($input_vars_num as $var_name) {
$$var_name = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null;
}
// Passkey
$passkey = isset($$passkey_key) ? $$passkey_key : null;
// Verify request
// Required params (info_hash, peer_id, port, uploaded, downloaded, left, passkey)
if (!isset($info_hash) || strlen($info_hash) != 20)
{
msg_die('Invalid info_hash');
if (!isset($info_hash) || strlen($info_hash) != 20) {
msg_die('Invalid info_hash');
}
if (!isset($peer_id) || strlen($peer_id) != 20)
{
msg_die('Invalid peer_id');
if (!isset($peer_id) || strlen($peer_id) != 20) {
msg_die('Invalid peer_id');
}
if (!isset($port) || $port < 0 || $port > 0xFFFF)
{
msg_die('Invalid port');
if (!isset($port) || $port < 0 || $port > 0xFFFF) {
msg_die('Invalid port');
}
if (!isset($uploaded) || $uploaded < 0 || $uploaded > $max_up_down_val || $uploaded == 1844674407370)
{
msg_die('Invalid uploaded value');
if (!isset($uploaded) || $uploaded < 0 || $uploaded > $max_up_down_val || $uploaded == 1844674407370) {
msg_die('Invalid uploaded value');
}
if (!isset($downloaded) || $downloaded < 0 || $downloaded > $max_up_down_val || $downloaded == 1844674407370)
{
msg_die('Invalid downloaded value');
if (!isset($downloaded) || $downloaded < 0 || $downloaded > $max_up_down_val || $downloaded == 1844674407370) {
msg_die('Invalid downloaded value');
}
if (!isset($left) || $left < 0 || $left > $max_left_val)
{
msg_die('Invalid left value');
if (!isset($left) || $left < 0 || $left > $max_left_val) {
msg_die('Invalid left value');
}
if (!verify_id($passkey, BT_AUTH_KEY_LENGTH))
{
msg_die('Invalid passkey');
if (!verify_id($passkey, BT_AUTH_KEY_LENGTH)) {
msg_die('Invalid passkey');
}
// IP
$ip = $_SERVER['REMOTE_ADDR'];
if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip'])
{
if (!$bb_cfg['verify_reported_ip'])
{
$ip = $_GET['ip'];
}
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches))
{
foreach ($matches[0] as $x_ip)
{
if ($x_ip === $_GET['ip'])
{
if (!$bb_cfg['allow_internal_ip'] && preg_match("#^(10|172\.16|192\.168)\.#", $x_ip))
{
break;
}
$ip = $x_ip;
break;
}
}
}
if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip']) {
if (!$bb_cfg['verify_reported_ip']) {
$ip = $_GET['ip'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) {
foreach ($matches[0] as $x_ip) {
if ($x_ip === $_GET['ip']) {
if (!$bb_cfg['allow_internal_ip'] && preg_match("#^(10|172\.16|192\.168)\.#", $x_ip)) {
break;
}
$ip = $x_ip;
break;
}
}
}
}
// Check that IP format is valid
if (!verify_ip($ip))
{
msg_die("Invalid IP: $ip");
if (!verify_ip($ip)) {
msg_die("Invalid IP: $ip");
}
// Convert IP to HEX format
$ip_sql = encode_ip($ip);
// Peer unique id
$peer_hash = md5(
rtrim($info_hash, ' ') . $passkey . $ip . $port
rtrim($info_hash, ' ') . $passkey . $ip . $port
);
// Get cached peer info from previous announce (last peer info)
$lp_info = CACHE('tr_cache')->get(PEER_HASH_PREFIX . $peer_hash);
if (DBG_LOG) dbg_log(' ', '$lp_info-get_from-CACHE-'. ($lp_info ? 'hit' : 'miss'));
if (DBG_LOG) {
dbg_log(' ', '$lp_info-get_from-CACHE-' . ($lp_info ? 'hit' : 'miss'));
}
// Drop fast announce
if ($lp_info && (!isset($event) || $event !== 'stopped'))
{
drop_fast_announce($lp_info);
if ($lp_info && (!isset($event) || $event !== 'stopped')) {
drop_fast_announce($lp_info);
}
// Functions
function drop_fast_announce ($lp_info)
function drop_fast_announce($lp_info)
{
global $announce_interval;
global $announce_interval;
if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60))
{
return; // if announce interval correct
}
if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60)) {
return; // if announce interval correct
}
$new_ann_intrv = $lp_info['update_time'] + $announce_interval - TIMENOW;
$new_ann_intrv = $lp_info['update_time'] + $announce_interval - TIMENOW;
dummy_exit($new_ann_intrv);
dummy_exit($new_ann_intrv);
}
function msg_die ($msg)
function msg_die($msg)
{
if (DBG_LOG) dbg_log(' ', '!die-'. clean_filename($msg));
if (DBG_LOG) {
dbg_log(' ', '!die-' . clean_filename($msg));
}
$output = bencode(array(
$output = bencode(array(
# 'interval' => (int) 1800,
'min interval' => (int) 1800,
'min interval' => (int)1800,
# 'peers' => (string) DUMMY_PEER,
'failure reason' => (string) $msg,
'warning message' => (string) $msg,
));
'failure reason' => (string)$msg,
'warning message' => (string)$msg,
));
die($output);
die($output);
}
# $agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-';
@ -189,160 +194,137 @@ function msg_die ($msg)
define('TR_ROOT', './');
require(TR_ROOT . 'includes/init_tr.php');
$seeder = ($left == 0) ? 1 : 0;
$seeder = ($left == 0) ? 1 : 0;
$stopped = ($event === 'stopped');
// Stopped event
if ($stopped)
{
CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
if (DBG_LOG) dbg_log(' ', 'stopped');
if ($stopped) {
CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
if (DBG_LOG) {
dbg_log(' ', 'stopped');
}
}
// Get last peer info from DB
if (!CACHE('tr_cache')->used && !$lp_info)
{
$lp_info = DB()->fetch_row("
SELECT * FROM ". BB_BT_TRACKER ." WHERE peer_hash = '$peer_hash' LIMIT 1
if (!CACHE('tr_cache')->used && !$lp_info) {
$lp_info = DB()->fetch_row("
SELECT * FROM " . BB_BT_TRACKER . " WHERE peer_hash = '$peer_hash' LIMIT 1
");
if (DBG_LOG) dbg_log(' ', '$lp_info-get_from-DB-'. ($lp_info ? 'hit' : 'miss'));
if (DBG_LOG) {
dbg_log(' ', '$lp_info-get_from-DB-' . ($lp_info ? 'hit' : 'miss'));
}
}
if ($lp_info)
{
if (!$stopped)
{
drop_fast_announce($lp_info);
}
if ($lp_info) {
if (!$stopped) {
drop_fast_announce($lp_info);
}
$user_id = $lp_info['user_id'];
$topic_id = $lp_info['topic_id'];
$releaser = $lp_info['releaser'];
$tor_type = $lp_info['tor_type'];
}
else
{
// Verify if torrent registered on tracker and user authorized
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$passkey_sql = DB()->escape($passkey);
$user_id = $lp_info['user_id'];
$topic_id = $lp_info['topic_id'];
$releaser = $lp_info['releaser'];
$tor_type = $lp_info['tor_type'];
} else {
// Verify if torrent registered on tracker and user authorized
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$passkey_sql = DB()->escape($passkey);
$sql = "
$sql = "
SELECT tor.topic_id, tor.poster_id, tor.tor_type, u.*
FROM ". BB_BT_TORRENTS ." tor
LEFT JOIN ". BB_BT_USERS ." u ON u.auth_key = '$passkey_sql'
FROM " . BB_BT_TORRENTS . " tor
LEFT JOIN " . BB_BT_USERS . " u ON u.auth_key = '$passkey_sql'
WHERE tor.info_hash = '$info_hash_sql'
LIMIT 1
";
$row = DB()->fetch_row($sql);
$row = DB()->fetch_row($sql);
if (empty($row['topic_id']))
{
msg_die('Torrent not registered, info_hash = ' . bin2hex($info_hash_sql));
}
if (empty($row['user_id']))
{
msg_die('Please LOG IN and REDOWNLOAD this torrent (user not found)');
}
if (empty($row['topic_id'])) {
msg_die('Torrent not registered, info_hash = ' . bin2hex($info_hash_sql));
}
if (empty($row['user_id'])) {
msg_die('Please LOG IN and REDOWNLOAD this torrent (user not found)');
}
$user_id = $row['user_id'];
$topic_id = $row['topic_id'];
$releaser = (int) ($user_id == $row['poster_id']);
$tor_type = $row['tor_type'];
$user_id = $row['user_id'];
$topic_id = $row['topic_id'];
$releaser = (int)($user_id == $row['poster_id']);
$tor_type = $row['tor_type'];
// Ratio limits
if ((TR_RATING_LIMITS || $tr_cfg['limit_concurrent_ips']) && !$stopped)
{
$user_ratio = ($row['u_down_total'] && $row['u_down_total'] > MIN_DL_FOR_RATIO) ? ($row['u_up_total'] + $row['u_up_release'] + $row['u_up_bonus']) / $row['u_down_total'] : 1;
$rating_msg = '';
// Ratio limits
if ((TR_RATING_LIMITS || $tr_cfg['limit_concurrent_ips']) && !$stopped) {
$user_ratio = ($row['u_down_total'] && $row['u_down_total'] > MIN_DL_FOR_RATIO) ? ($row['u_up_total'] + $row['u_up_release'] + $row['u_up_bonus']) / $row['u_down_total'] : 1;
$rating_msg = '';
if (!$seeder)
{
foreach ($rating_limits as $ratio => $limit)
{
if ($user_ratio < $ratio)
{
$tr_cfg['limit_active_tor'] = 1;
$tr_cfg['limit_leech_count'] = $limit;
$rating_msg = " (ratio < $ratio)";
break;
}
}
}
if (!$seeder) {
foreach ($rating_limits as $ratio => $limit) {
if ($user_ratio < $ratio) {
$tr_cfg['limit_active_tor'] = 1;
$tr_cfg['limit_leech_count'] = $limit;
$rating_msg = " (ratio < $ratio)";
break;
}
}
}
// Limit active torrents
if (!isset($bb_cfg['unlimited_users'][$user_id]) && $tr_cfg['limit_active_tor'] && (($tr_cfg['limit_seed_count'] && $seeder) || ($tr_cfg['limit_leech_count'] && !$seeder)))
{
$sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
FROM ". BB_BT_TRACKER ."
// Limit active torrents
if (!isset($bb_cfg['unlimited_users'][$user_id]) && $tr_cfg['limit_active_tor'] && (($tr_cfg['limit_seed_count'] && $seeder) || ($tr_cfg['limit_leech_count'] && !$seeder))) {
$sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
FROM " . BB_BT_TRACKER . "
WHERE user_id = $user_id
AND seeder = $seeder
AND topic_id != $topic_id";
if (!$seeder && $tr_cfg['leech_expire_factor'] && $user_ratio < 0.5)
{
$sql .= " AND update_time > ". (TIMENOW - 60*$tr_cfg['leech_expire_factor']);
}
$sql .= " GROUP BY user_id";
if (!$seeder && $tr_cfg['leech_expire_factor'] && $user_ratio < 0.5) {
$sql .= " AND update_time > " . (TIMENOW - 60 * $tr_cfg['leech_expire_factor']);
}
$sql .= " GROUP BY user_id";
if ($row = DB()->fetch_row($sql))
{
if ($seeder && $tr_cfg['limit_seed_count'] && $row['active_torrents'] >= $tr_cfg['limit_seed_count'])
{
msg_die('Only '. $tr_cfg['limit_seed_count'] .' torrent(s) allowed for seeding');
}
elseif (!$seeder && $tr_cfg['limit_leech_count'] && $row['active_torrents'] >= $tr_cfg['limit_leech_count'])
{
msg_die('Only '. $tr_cfg['limit_leech_count'] .' torrent(s) allowed for leeching'. $rating_msg);
}
}
}
if ($row = DB()->fetch_row($sql)) {
if ($seeder && $tr_cfg['limit_seed_count'] && $row['active_torrents'] >= $tr_cfg['limit_seed_count']) {
msg_die('Only ' . $tr_cfg['limit_seed_count'] . ' torrent(s) allowed for seeding');
} elseif (!$seeder && $tr_cfg['limit_leech_count'] && $row['active_torrents'] >= $tr_cfg['limit_leech_count']) {
msg_die('Only ' . $tr_cfg['limit_leech_count'] . ' torrent(s) allowed for leeching' . $rating_msg);
}
}
}
// Limit concurrent IPs
if ($tr_cfg['limit_concurrent_ips'] && (($tr_cfg['limit_seed_ips'] && $seeder) || ($tr_cfg['limit_leech_ips'] && !$seeder)))
{
$sql = "SELECT COUNT(DISTINCT ip) AS ips
FROM ". BB_BT_TRACKER ."
// Limit concurrent IPs
if ($tr_cfg['limit_concurrent_ips'] && (($tr_cfg['limit_seed_ips'] && $seeder) || ($tr_cfg['limit_leech_ips'] && !$seeder))) {
$sql = "SELECT COUNT(DISTINCT ip) AS ips
FROM " . BB_BT_TRACKER . "
WHERE topic_id = $topic_id
AND user_id = $user_id
AND seeder = $seeder
AND ip != '$ip_sql'";
if (!$seeder && $tr_cfg['leech_expire_factor'])
{
$sql .= " AND update_time > ". (TIMENOW - 60*$tr_cfg['leech_expire_factor']);
}
$sql .= " GROUP BY topic_id";
if (!$seeder && $tr_cfg['leech_expire_factor']) {
$sql .= " AND update_time > " . (TIMENOW - 60 * $tr_cfg['leech_expire_factor']);
}
$sql .= " GROUP BY topic_id";
if ($row = DB()->fetch_row($sql))
{
if ($seeder && $tr_cfg['limit_seed_ips'] && $row['ips'] >= $tr_cfg['limit_seed_ips'])
{
msg_die('You can seed only from '. $tr_cfg['limit_seed_ips'] ." IP's");
}
elseif (!$seeder && $tr_cfg['limit_leech_ips'] && $row['ips'] >= $tr_cfg['limit_leech_ips'])
{
msg_die('You can leech only from '. $tr_cfg['limit_leech_ips'] ." IP's");
}
}
}
}
if ($row = DB()->fetch_row($sql)) {
if ($seeder && $tr_cfg['limit_seed_ips'] && $row['ips'] >= $tr_cfg['limit_seed_ips']) {
msg_die('You can seed only from ' . $tr_cfg['limit_seed_ips'] . " IP's");
} elseif (!$seeder && $tr_cfg['limit_leech_ips'] && $row['ips'] >= $tr_cfg['limit_leech_ips']) {
msg_die('You can leech only from ' . $tr_cfg['limit_leech_ips'] . " IP's");
}
}
}
}
}
// Up/Down speed
$speed_up = $speed_down = 0;
if ($lp_info && $lp_info['update_time'] < TIMENOW)
{
if ($uploaded > $lp_info['uploaded'])
{
$speed_up = ceil(($uploaded - $lp_info['uploaded']) / (TIMENOW - $lp_info['update_time']));
}
if ($downloaded > $lp_info['downloaded'])
{
$speed_down = ceil(($downloaded - $lp_info['downloaded']) / (TIMENOW - $lp_info['update_time']));
}
if ($lp_info && $lp_info['update_time'] < TIMENOW) {
if ($uploaded > $lp_info['uploaded']) {
$speed_up = ceil(($uploaded - $lp_info['uploaded']) / (TIMENOW - $lp_info['update_time']));
}
if ($downloaded > $lp_info['downloaded']) {
$speed_down = ceil(($downloaded - $lp_info['downloaded']) / (TIMENOW - $lp_info['update_time']));
}
}
// Up/Down addition
@ -350,156 +332,152 @@ $up_add = ($lp_info && $uploaded > $lp_info['uploaded']) ? $uploaded - $lp_info[
$down_add = ($lp_info && $downloaded > $lp_info['downloaded']) ? $downloaded - $lp_info['downloaded'] : 0;
// Gold/Silver releases
if ($tr_cfg['gold_silver_enabled'] && $down_add)
{
if ($tor_type == TOR_TYPE_GOLD)
{
$down_add = 0;
}
// Silver releases
elseif ($tor_type == TOR_TYPE_SILVER)
{
$down_add = ceil($down_add/2);
}
if ($tr_cfg['gold_silver_enabled'] && $down_add) {
if ($tor_type == TOR_TYPE_GOLD) {
$down_add = 0;
} // Silver releases
elseif ($tor_type == TOR_TYPE_SILVER) {
$down_add = ceil($down_add / 2);
}
}
// Insert/update peer info
$peer_info_updated = false;
$update_time = ($stopped) ? 0 : TIMENOW;
if ($lp_info)
{
$sql = "UPDATE ". BB_BT_TRACKER ." SET update_time = $update_time";
if ($lp_info) {
$sql = "UPDATE " . BB_BT_TRACKER . " SET update_time = $update_time";
$sql .= ", seeder = $seeder";
$sql .= ($releaser != $lp_info['releaser']) ? ", releaser = $releaser" : '';
$sql .= ", seeder = $seeder";
$sql .= ($releaser != $lp_info['releaser']) ? ", releaser = $releaser" : '';
$sql .= ($tor_type != $lp_info['tor_type']) ? ", tor_type = $tor_type" : '';
$sql .= ($tor_type != $lp_info['tor_type']) ? ", tor_type = $tor_type" : '';
$sql .= ($uploaded != $lp_info['uploaded']) ? ", uploaded = $uploaded" : '';
$sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
$sql .= ", remain = $left";
$sql .= ($uploaded != $lp_info['uploaded']) ? ", uploaded = $uploaded" : '';
$sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
$sql .= ", remain = $left";
$sql .= ($up_add) ? ", up_add = up_add + $up_add" : '';
$sql .= ($down_add) ? ", down_add = down_add + $down_add" : '';
$sql .= ($up_add) ? ", up_add = up_add + $up_add" : '';
$sql .= ($down_add) ? ", down_add = down_add + $down_add" : '';
$sql .= ", speed_up = $speed_up";
$sql .= ", speed_down = $speed_down";
$sql .= ", speed_up = $speed_up";
$sql .= ", speed_down = $speed_down";
$sql .= " WHERE peer_hash = '$peer_hash'";
$sql .= " LIMIT 1";
$sql .= " WHERE peer_hash = '$peer_hash'";
$sql .= " LIMIT 1";
DB()->query($sql);
DB()->query($sql);
$peer_info_updated = DB()->affected_rows();
$peer_info_updated = DB()->affected_rows();
if (DBG_LOG) dbg_log(' ', 'this_peer-update'. ($peer_info_updated ? '' : '-FAIL'));
if (DBG_LOG) {
dbg_log(' ', 'this_peer-update' . ($peer_info_updated ? '' : '-FAIL'));
}
}
if (!$lp_info || !$peer_info_updated)
{
$columns = 'peer_hash, topic_id, user_id, ip, port, seeder, releaser, tor_type, uploaded, downloaded, remain, speed_up, speed_down, up_add, down_add, update_time';
$values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time";
if (!$lp_info || !$peer_info_updated) {
$columns = 'peer_hash, topic_id, user_id, ip, port, seeder, releaser, tor_type, uploaded, downloaded, remain, speed_up, speed_down, up_add, down_add, update_time';
$values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time";
DB()->query("REPLACE INTO ". BB_BT_TRACKER ." ($columns) VALUES ($values)");
DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)");
if (DBG_LOG) dbg_log(' ', 'this_peer-insert');
if (DBG_LOG) {
dbg_log(' ', 'this_peer-insert');
}
}
// Exit if stopped
if ($stopped)
{
silent_exit();
if ($stopped) {
silent_exit();
}
// Store peer info in cache
$lp_info = array(
'downloaded' => (float) $downloaded,
'releaser' => (int) $releaser,
'seeder' => (int) $seeder,
'topic_id' => (int) $topic_id,
'update_time' => (int) TIMENOW,
'uploaded' => (float) $uploaded,
'user_id' => (int) $user_id,
'tor_type' => (int) $tor_type,
'downloaded' => (float)$downloaded,
'releaser' => (int)$releaser,
'seeder' => (int)$seeder,
'topic_id' => (int)$topic_id,
'update_time' => (int)TIMENOW,
'uploaded' => (float)$uploaded,
'user_id' => (int)$user_id,
'tor_type' => (int)$tor_type,
);
$lp_info_cached = CACHE('tr_cache')->set(PEER_HASH_PREFIX . $peer_hash, $lp_info, PEER_HASH_EXPIRE);
if (DBG_LOG && !$lp_info_cached) dbg_log(' ', '$lp_info-caching-FAIL');
if (DBG_LOG && !$lp_info_cached) {
dbg_log(' ', '$lp_info-caching-FAIL');
}
// Get cached output
$output = CACHE('tr_cache')->get(PEERS_LIST_PREFIX . $topic_id);
if (DBG_LOG) dbg_log(' ', '$output-get_from-CACHE-'. ($output !== false ? 'hit' : 'miss'));
if (DBG_LOG) {
dbg_log(' ', '$output-get_from-CACHE-' . ($output !== false ? 'hit' : 'miss'));
}
if (!$output)
{
// Retrieve peers
$numwant = (int) $tr_cfg['numwant'];
$compact_mode = ($tr_cfg['compact_mode'] || !empty($compact));
if (!$output) {
// Retrieve peers
$numwant = (int)$tr_cfg['numwant'];
$compact_mode = ($tr_cfg['compact_mode'] || !empty($compact));
$rowset = DB()->fetch_rowset("
$rowset = DB()->fetch_rowset("
SELECT ip, port
FROM ". BB_BT_TRACKER ."
FROM " . BB_BT_TRACKER . "
WHERE topic_id = $topic_id
ORDER BY RAND()
LIMIT $numwant
");
if ($compact_mode)
{
$peers = '';
if ($compact_mode) {
$peers = '';
foreach ($rowset as $peer)
{
$peers .= pack('Nn', ip2long(decode_ip($peer['ip'])), $peer['port']);
}
}
else
{
$peers = array();
foreach ($rowset as $peer) {
$peers .= pack('Nn', ip2long(decode_ip($peer['ip'])), $peer['port']);
}
} else {
$peers = array();
foreach ($rowset as $peer)
{
$peers[] = array(
'ip' => decode_ip($peer['ip']),
'port' => intval($peer['port']),
);
}
}
foreach ($rowset as $peer) {
$peers[] = array(
'ip' => decode_ip($peer['ip']),
'port' => intval($peer['port']),
);
}
}
$seeders = 0;
$leechers = 0;
$seeders = 0;
$leechers = 0;
if ($tr_cfg['scrape'])
{
$row = DB()->fetch_row("
if ($tr_cfg['scrape']) {
$row = DB()->fetch_row("
SELECT seeders, leechers
FROM ". BB_BT_TRACKER_SNAP ."
FROM " . BB_BT_TRACKER_SNAP . "
WHERE topic_id = $topic_id
LIMIT 1
");
$seeders = $row['seeders'];
$leechers = $row['leechers'];
}
$seeders = $row['seeders'];
$leechers = $row['leechers'];
}
$output = array(
'interval' => (int) $announce_interval,
'min interval' => (int) $announce_interval,
'peers' => $peers,
'complete' => (int) $seeders,
'incomplete' => (int) $leechers,
);
$output = array(
'interval' => (int)$announce_interval,
'min interval' => (int)$announce_interval,
'peers' => $peers,
'complete' => (int)$seeders,
'incomplete' => (int)$leechers,
);
$peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
$peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
if (DBG_LOG && !$peers_list_cached) dbg_log(' ', '$output-caching-FAIL');
if (DBG_LOG && !$peers_list_cached) {
dbg_log(' ', '$output-caching-FAIL');
}
}
// Return data to client
echo bencode($output);
tracker_exit();
exit;
exit;

View file

@ -1,489 +1,495 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_TRACKER')) die(basename(__FILE__));
if (!defined('IN_TRACKER')) {
die(basename(__FILE__));
}
// Exit if tracker is disabled
if ($tr_cfg['off']) tr_die($tr_cfg['off_reason']);
if ($tr_cfg['off']) {
tr_die($tr_cfg['off_reason']);
}
//
// Functions
//
function tracker_exit ()
function tracker_exit()
{
global $DBS;
global $DBS;
if (DBG_LOG && DBG_TRACKER)
{
if ($gen_time = utime() - TIMESTART)
{
$sql_init_perc = round($DBS->sql_inittime*100/$gen_time);
$sql_total_perc = round($DBS->sql_timetotal*100/$gen_time);
if (DBG_LOG && DBG_TRACKER) {
if ($gen_time = utime() - TIMESTART) {
$sql_init_perc = round($DBS->sql_inittime * 100 / $gen_time);
$sql_total_perc = round($DBS->sql_timetotal * 100 / $gen_time);
$str = array();
$str[] = substr(TIMENOW, -4, 4);
$str[] = sprintf('%.4f', $gen_time);
$str[] = sprintf('%.4f'. LOG_SEPR .'%02d%%', $DBS->sql_inittime, $sql_init_perc);
$str[] = sprintf('%.4f'. LOG_SEPR .'%02d%%', $DBS->sql_timetotal, $sql_total_perc);
$str[] = $DBS->num_queries;
$str[] = sprintf('%.1f', sys('la'));
$str = join(LOG_SEPR, $str) . LOG_LF;
dbg_log($str, '!!gentime');
}
}
exit;
$str = array();
$str[] = substr(TIMENOW, -4, 4);
$str[] = sprintf('%.4f', $gen_time);
$str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_inittime, $sql_init_perc);
$str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_timetotal, $sql_total_perc);
$str[] = $DBS->num_queries;
$str[] = sprintf('%.1f', sys('la'));
$str = join(LOG_SEPR, $str) . LOG_LF;
dbg_log($str, '!!gentime');
}
}
exit;
}
function silent_exit ()
function silent_exit()
{
while (@ob_end_clean());
while (@ob_end_clean()) ;
tracker_exit();
tracker_exit();
}
function error_exit ($msg = '')
function error_exit($msg = '')
{
if (DBG_LOG) dbg_log(' ', '!err-'. clean_filename($msg));
if (DBG_LOG) {
dbg_log(' ', '!err-' . clean_filename($msg));
}
silent_exit();
silent_exit();
echo bencode(array('failure reason' => str_compact($msg)));
echo bencode(array('failure reason' => str_compact($msg)));
tracker_exit();
tracker_exit();
}
// Database
class sql_db
{
public $cfg = array();
public $cfg_keys = array('dbhost', 'dbname', 'dbuser', 'dbpasswd', 'charset', 'persist');
public $link = null;
public $result = null;
public $db_server = '';
public $selected_db = null;
public $cfg = array();
public $cfg_keys = array('dbhost', 'dbname', 'dbuser', 'dbpasswd', 'charset', 'persist');
public $link = null;
public $result = null;
public $db_server = '';
public $selected_db = null;
public $locked = false;
public $locked = false;
public $num_queries = 0;
public $sql_starttime = 0;
public $sql_inittime = 0;
public $sql_timetotal = 0;
public $sql_last_time = 0;
public $slow_time = 0;
public $num_queries = 0;
public $sql_starttime = 0;
public $sql_inittime = 0;
public $sql_timetotal = 0;
public $sql_last_time = 0;
public $slow_time = 0;
public $dbg = array();
public $dbg_id = 0;
public $dbg_enabled = false;
public $cur_query = null;
public $dbg = array();
public $dbg_id = 0;
public $dbg_enabled = false;
public $cur_query = null;
public $DBS = array();
public $DBS = array();
/**
* Constructor
*/
function __construct ($cfg_values)
{
global $DBS;
/**
* Constructor
*/
public function __construct($cfg_values)
{
global $DBS;
$this->cfg = array_combine($this->cfg_keys, $cfg_values);
$this->dbg_enabled = sql_dbg_enabled();
$this->slow_time = SQL_SLOW_QUERY_TIME;
$this->cfg = array_combine($this->cfg_keys, $cfg_values);
$this->dbg_enabled = sql_dbg_enabled();
$this->slow_time = SQL_SLOW_QUERY_TIME;
$this->DBS['num_queries'] =& $DBS->num_queries;
$this->DBS['sql_inittime'] =& $DBS->sql_inittime;
$this->DBS['sql_timetotal'] =& $DBS->sql_timetotal;
}
$this->DBS['num_queries'] =& $DBS->num_queries;
$this->DBS['sql_inittime'] =& $DBS->sql_inittime;
$this->DBS['sql_timetotal'] =& $DBS->sql_timetotal;
}
/**
* Initialize connection
*/
function init ()
{
// Connect to server
$this->link = $this->connect();
/**
* Initialize connection
*/
public function init()
{
// Connect to server
$this->link = $this->connect();
// Select database
$this->selected_db = $this->select_db();
// Select database
$this->selected_db = $this->select_db();
// Set charset
if ($this->cfg['charset'] && !@mysql_set_charset($this->cfg['charset'], $this->link))
{
if (!$this->sql_query("SET NAMES {$this->cfg['charset']}"))
{
error_exit("Could not set charset {$this->cfg['charset']}");
}
}
// Set charset
if ($this->cfg['charset'] && !@mysql_set_charset($this->cfg['charset'], $this->link)) {
if (!$this->sql_query("SET NAMES {$this->cfg['charset']}")) {
error_exit("Could not set charset {$this->cfg['charset']}");
}
}
$this->num_queries = 0;
$this->sql_inittime = $this->sql_timetotal;
$this->DBS['sql_inittime'] += $this->sql_inittime;
}
$this->num_queries = 0;
$this->sql_inittime = $this->sql_timetotal;
$this->DBS['sql_inittime'] += $this->sql_inittime;
}
/**
* Open connection
*/
function connect ()
{
$this->cur_query = 'connect';
$this->debug('start');
/**
* Open connection
*/
public function connect()
{
$this->cur_query = 'connect';
$this->debug('start');
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
if (!$link = $connect_type($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd']))
{
$this->log_error();
}
if (!$link = $connect_type($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd'])) {
$this->log_error();
}
register_shutdown_function(array(&$this, 'close'));
register_shutdown_function(array(&$this, 'close'));
$this->debug('end');
$this->cur_query = null;
$this->debug('end');
$this->cur_query = null;
# if (DBG_LOG) dbg_log(' ', 'DB-connect'. ($link ? '' : '-FAIL'));
if (!$link)
{
if (function_exists('dummy_exit'))
{
dummy_exit(mt_rand(1200, 2400));
}
else
{
die;
}
}
if (!$link) {
if (function_exists('dummy_exit')) {
dummy_exit(mt_rand(1200, 2400));
} else {
die;
}
}
return $link;
}
return $link;
}
/**
* Select database
*/
function select_db ()
{
$this->cur_query = 'select db';
$this->debug('start');
/**
* Select database
*/
public function select_db()
{
$this->cur_query = 'select db';
$this->debug('start');
if (!mysql_select_db($this->cfg['dbname'], $this->link))
{
$this->log_error();
error_exit("Could not select database '{$this->cfg['dbname']}'");
}
if (!mysql_select_db($this->cfg['dbname'], $this->link)) {
$this->log_error();
error_exit("Could not select database '{$this->cfg['dbname']}'");
}
$this->debug('end');
$this->cur_query = null;
$this->debug('end');
$this->cur_query = null;
return $this->cfg['dbname'];
}
return $this->cfg['dbname'];
}
/**
* Base query method
*/
function sql_query ($query)
{
if (!is_resource($this->link))
{
$this->init();
}
$this->cur_query = $query;
$this->debug('start');
/**
* Base query method
*/
public function sql_query($query)
{
if (!is_resource($this->link)) {
$this->init();
}
$this->cur_query = $query;
$this->debug('start');
if (!$this->result = mysql_query($query, $this->link))
{
$this->log_error();
}
if (!$this->result = mysql_query($query, $this->link)) {
$this->log_error();
}
$this->debug('end');
$this->cur_query = null;
$this->debug('end');
$this->cur_query = null;
$this->num_queries++;
$this->DBS['num_queries']++;
$this->num_queries++;
$this->DBS['num_queries']++;
return $this->result;
}
return $this->result;
}
/**
* Execute query WRAPPER (with error handling)
*/
function query ($query)
{
if (!$result = $this->sql_query($query))
{
$this->trigger_error();
}
/**
* Execute query WRAPPER (with error handling)
*/
public function query($query)
{
if (!$result = $this->sql_query($query)) {
$this->trigger_error();
}
return $result;
}
return $result;
}
/**
* Return number of rows
*/
function num_rows ($result = false)
{
$num_rows = false;
/**
* Return number of rows
*/
public function num_rows($result = false)
{
$num_rows = false;
if ($result OR $result = $this->result)
{
$num_rows = is_resource($result) ? mysql_num_rows($result) : false;
}
if ($result or $result = $this->result) {
$num_rows = is_resource($result) ? mysql_num_rows($result) : false;
}
return $num_rows;
}
return $num_rows;
}
/**
* Return number of affected rows
*/
function affected_rows ()
{
return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
}
/**
* Return number of affected rows
*/
public function affected_rows()
{
return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
}
/**
* Fetch current row
*/
function sql_fetchrow ($result)
{
return is_resource($result) ? mysql_fetch_assoc($result) : false;
}
/**
* Fetch current row
*/
public function sql_fetchrow($result)
{
return is_resource($result) ? mysql_fetch_assoc($result) : false;
}
/**
* Alias of sql_fetchrow()
*/
function fetch_next ($result)
{
return $this->sql_fetchrow($result);
}
/**
* Alias of sql_fetchrow()
*/
public function fetch_next($result)
{
return $this->sql_fetchrow($result);
}
/**
* Fetch row WRAPPER (with error handling)
*/
function fetch_row ($query)
{
if (!$result = $this->sql_query($query))
{
$this->trigger_error();
}
/**
* Fetch row WRAPPER (with error handling)
*/
public function fetch_row($query)
{
if (!$result = $this->sql_query($query)) {
$this->trigger_error();
}
return $this->sql_fetchrow($result);
}
return $this->sql_fetchrow($result);
}
/**
* Fetch all rows
*/
function sql_fetchrowset ($result)
{
$rowset = array();
/**
* Fetch all rows
*/
public function sql_fetchrowset($result)
{
$rowset = array();
while ($row = mysql_fetch_assoc($result))
{
$rowset[] = $row;
}
while ($row = mysql_fetch_assoc($result)) {
$rowset[] = $row;
}
return $rowset;
}
return $rowset;
}
/**
* Fetch all rows WRAPPER (with error handling)
*/
function fetch_rowset ($query)
{
if (!$result = $this->sql_query($query))
{
$this->trigger_error();
}
/**
* Fetch all rows WRAPPER (with error handling)
*/
public function fetch_rowset($query)
{
if (!$result = $this->sql_query($query)) {
$this->trigger_error();
}
return $this->sql_fetchrowset($result);
}
return $this->sql_fetchrowset($result);
}
/**
* Escape string used in sql query
*/
function escape ($v, $check_type = false)
{
if (!is_resource($this->link))
{
$this->init();
}
if (!$check_type)
{
return mysql_real_escape_string($v);
}
/**
* Escape string used in sql query
*/
public function escape($v, $check_type = false)
{
if (!is_resource($this->link)) {
$this->init();
}
if (!$check_type) {
return mysql_real_escape_string($v);
}
switch (true)
{
case is_string ($v): return "'". mysql_real_escape_string($v) ."'";
case is_int ($v): return "$v";
case is_bool ($v): return ($v) ? '1' : '0';
case is_float ($v): return "'$v'";
case is_null ($v): return 'NULL';
}
// if $v has unsuitable type
$this->trigger_error(__FUNCTION__ .' - wrong params');
}
switch (true) {
case is_string($v):
return "'" . mysql_real_escape_string($v) . "'";
case is_int($v):
return "$v";
case is_bool($v):
return ($v) ? '1' : '0';
case is_float($v):
return "'$v'";
case is_null($v):
return 'NULL';
}
// if $v has unsuitable type
$this->trigger_error(__FUNCTION__ . ' - wrong params');
}
/**
* Return sql error array
*/
function sql_error ()
{
$return_ary = array(
'code' => '',
'message' => 'not connected',
);
/**
* Return sql error array
*/
public function sql_error()
{
$return_ary = array(
'code' => '',
'message' => 'not connected',
);
if (is_resource($this->link))
{
$return_ary = array(
'code' => mysql_errno($this->link),
'message' => mysql_error($this->link),
);
}
if (is_resource($this->link)) {
$return_ary = array(
'code' => mysql_errno($this->link),
'message' => mysql_error($this->link),
);
}
return $return_ary;
}
return $return_ary;
}
/**
* Close sql connection
*/
function close ()
{
if (is_resource($this->link))
{
mysql_close($this->link);
}
/**
* Close sql connection
*/
public function close()
{
if (is_resource($this->link)) {
mysql_close($this->link);
}
$this->link = $this->selected_db = null;
$this->link = $this->selected_db = null;
if (DBG_LOG) dbg_log(str_repeat(' ', $this->num_queries), 'DB-num_queries-'. php_sapi_name());
}
if (DBG_LOG) {
dbg_log(str_repeat(' ', $this->num_queries), 'DB-num_queries-' . php_sapi_name());
}
}
/**
* Get info about last query
*/
function query_info ()
{
$info = array();
/**
* Get info about last query
*/
public function query_info()
{
$info = array();
if ($num = $this->num_rows($this->result))
{
$info[] = "$num rows";
}
if ($num = $this->num_rows($this->result)) {
$info[] = "$num rows";
}
if (is_resource($this->link) AND $ext = mysql_info($this->link))
{
$info[] = "$ext";
}
elseif (!$num && ($aff = $this->affected_rows($this->result) AND $aff != -1))
{
$info[] = "$aff rows";
}
if (is_resource($this->link) and $ext = mysql_info($this->link)) {
$info[] = "$ext";
} elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) {
$info[] = "$aff rows";
}
return join(', ', $info);
}
return join(', ', $info);
}
/**
* Store debug info
*/
function debug ($mode)
{
if (!SQL_DEBUG) return;
/**
* Store debug info
*/
public function debug($mode)
{
if (!SQL_DEBUG) {
return;
}
if ($mode == 'start')
{
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
{
$this->sql_starttime = utime();
$this->sql_last_time = 0;
}
}
elseif ($mode == 'end')
{
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
{
$this->sql_last_time = utime() - $this->sql_starttime;
$this->sql_timetotal += $this->sql_last_time;
$this->DBS['sql_timetotal'] += $this->sql_last_time;
if ($mode == 'start') {
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) {
$this->sql_starttime = utime();
$this->sql_last_time = 0;
}
} elseif ($mode == 'end') {
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) {
$this->sql_last_time = utime() - $this->sql_starttime;
$this->sql_timetotal += $this->sql_last_time;
$this->DBS['sql_timetotal'] += $this->sql_last_time;
if (SQL_LOG_SLOW_QUERIES && $this->sql_last_time > $this->slow_time)
{
$msg = date('m-d H:i:s') . LOG_SEPR;
$msg .= sprintf('%03d', round($this->sql_last_time));
$msg .= LOG_SEPR . sprintf('%.1f', sys('la'));
$msg .= LOG_SEPR . str_compact($this->cur_query);
$msg .= LOG_SEPR .' # '. $this->query_info();
$msg .= LOG_SEPR . $this->debug_find_source();
bb_log($msg . LOG_LF, 'sql_slow_tr');
}
}
}
return;
}
if (SQL_LOG_SLOW_QUERIES && $this->sql_last_time > $this->slow_time) {
$msg = date('m-d H:i:s') . LOG_SEPR;
$msg .= sprintf('%03d', round($this->sql_last_time));
$msg .= LOG_SEPR . sprintf('%.1f', sys('la'));
$msg .= LOG_SEPR . str_compact($this->cur_query);
$msg .= LOG_SEPR . ' # ' . $this->query_info();
$msg .= LOG_SEPR . $this->debug_find_source();
bb_log($msg . LOG_LF, 'sql_slow_tr');
}
}
}
return;
}
/**
* Trigger error
*/
function trigger_error ($msg = '')
{
if (error_reporting())
{
if (!$msg) $msg = 'DB Error';
/**
* Trigger error
*/
public function trigger_error($msg = '')
{
if (error_reporting()) {
if (!$msg) {
$msg = 'DB Error';
}
if (DBG_TRACKER === true)
{
$err = $this->sql_error();
$msg .= trim(sprintf(' #%06d %s', $err['code'], $err['message']));
}
else
{
$msg .= " [". $this->debug_find_source() ."]";
}
if (DBG_TRACKER === true) {
$err = $this->sql_error();
$msg .= trim(sprintf(' #%06d %s', $err['code'], $err['message']));
} else {
$msg .= " [" . $this->debug_find_source() . "]";
}
error_exit($msg);
}
}
error_exit($msg);
}
}
/**
* Find caller source
*/
function debug_find_source ()
{
$source = '';
$backtrace = debug_backtrace();
/**
* Find caller source
*/
public function debug_find_source()
{
$source = '';
$backtrace = debug_backtrace();
foreach ($backtrace as $trace)
{
if ($trace['file'] !== __FILE__)
{
$source = str_replace(BB_PATH, '', $trace['file']) .'('. $trace['line'] .')';
break;
}
}
foreach ($backtrace as $trace) {
if ($trace['file'] !== __FILE__) {
$source = str_replace(BB_PATH, '', $trace['file']) . '(' . $trace['line'] . ')';
break;
}
}
return $source;
}
return $source;
}
/**
* Log error
*/
function log_error ()
{
if (!SQL_LOG_ERRORS) return;
if (!error_reporting()) return;
/**
* Log error
*/
public function log_error()
{
if (!SQL_LOG_ERRORS) {
return;
}
if (!error_reporting()) {
return;
}
$msg = array();
$err = $this->sql_error();
$msg[] = str_compact(sprintf('#%06d %s', $err['code'], $err['message']));
$msg[] = '';
$msg[] = str_compact($this->cur_query);
$msg[] = '';
$msg[] = 'Source : '. $this->debug_find_source();
$msg[] = 'IP : '. @$_SERVER['REMOTE_ADDR'];
$msg[] = 'Date : '. date('Y-m-d H:i:s');
$msg[] = 'Agent : '. @$_SERVER['HTTP_USER_AGENT'];
$msg[] = 'Req_URI : '. @$_SERVER['REQUEST_URI'];
$msg[] = 'Referer : '. @$_SERVER['HTTP_REFERER'];
$msg[] = 'Method : '. @$_SERVER['REQUEST_METHOD'];
$msg[] = 'Request : '. trim(print_r($_REQUEST, true)) . str_repeat('_', 78) . LOG_LF;
$msg[] = '';
bb_log($msg, 'sql_error_tr');
}
$msg = array();
$err = $this->sql_error();
$msg[] = str_compact(sprintf('#%06d %s', $err['code'], $err['message']));
$msg[] = '';
$msg[] = str_compact($this->cur_query);
$msg[] = '';
$msg[] = 'Source : ' . $this->debug_find_source();
$msg[] = 'IP : ' . @$_SERVER['REMOTE_ADDR'];
$msg[] = 'Date : ' . date('Y-m-d H:i:s');
$msg[] = 'Agent : ' . @$_SERVER['HTTP_USER_AGENT'];
$msg[] = 'Req_URI : ' . @$_SERVER['REQUEST_URI'];
$msg[] = 'Referer : ' . @$_SERVER['HTTP_REFERER'];
$msg[] = 'Method : ' . @$_SERVER['REQUEST_METHOD'];
$msg[] = 'Request : ' . trim(print_r($_REQUEST, true)) . str_repeat('_', 78) . LOG_LF;
$msg[] = '';
bb_log($msg, 'sql_error_tr');
}
}

View file

@ -1,3 +1,26 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
require('./announce.php');
require('./announce.php');

View file

@ -1,35 +1,60 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_TRACKER', true);
define('BB_ROOT', './../');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
if (!$tr_cfg['scrape']) msg_die('Please disable SCRAPE!');
// Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash']))
{
$_GET['info_hash'] = $_GET['?info_hash'];
if (!$tr_cfg['scrape']) {
msg_die('Please disable SCRAPE!');
}
if (!isset($_GET['info_hash']) || strlen($_GET['info_hash']) != 20)
{
msg_die('Invalid info_hash');
// Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
$_GET['info_hash'] = $_GET['?info_hash'];
}
if (!isset($_GET['info_hash']) || strlen($_GET['info_hash']) != 20) {
msg_die('Invalid info_hash');
}
$info_hash = $_GET['info_hash'];
function msg_die ($msg)
function msg_die($msg)
{
if (DBG_LOG) dbg_log(' ', '!die-'. clean_filename($msg));
if (DBG_LOG) {
dbg_log(' ', '!die-' . clean_filename($msg));
}
$output = bencode(array(
'min interval' => (int) 1800,
'failure reason' => (string) $msg,
'warning message' => (string) $msg,
));
$output = bencode(array(
'min interval' => (int)1800,
'failure reason' => (string)$msg,
'warning message' => (string)$msg,
));
die($output);
die($output);
}
define('TR_ROOT', './');
@ -39,19 +64,19 @@ $info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$row = DB()->fetch_row("
SELECT tor.complete_count, snap.seeders, snap.leechers
FROM ". BB_BT_TORRENTS ." tor
LEFT JOIN ". BB_BT_TRACKER_SNAP ." snap ON (snap.topic_id = tor.topic_id)
FROM " . BB_BT_TORRENTS . " tor
LEFT JOIN " . BB_BT_TRACKER_SNAP . " snap ON (snap.topic_id = tor.topic_id)
WHERE tor.info_hash = '$info_hash_sql'
LIMIT 1
");
$output['files'][$info_hash] = array(
'complete' => (int) $row['seeders'],
'downloaded' => (int) $row['complete_count'],
'incomplete' => (int) $row['leechers'],
'complete' => (int)$row['seeders'],
'downloaded' => (int)$row['complete_count'],
'incomplete' => (int)$row['leechers'],
);
echo bencode($output);
tracker_exit();
exit;
exit;

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_SCRIPT', 'callseed');
@ -8,40 +31,36 @@ require(BB_ROOT . 'common.php');
// Init userdata
$user->session_start(array('req_login' => true));
$topic_id = (int) request_var('t', 0);
$t_data = topic_info($topic_id);
$topic_id = (int)request_var('t', 0);
$t_data = topic_info($topic_id);
$forum_id = $t_data['forum_id'];
set_die_append_msg($forum_id, $topic_id);
if ($t_data['seeders'] > 2)
{
bb_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders']));
}
elseif ($t_data['call_seed_time'] > (TIMENOW - 86400))
{
$time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
bb_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left));
if ($t_data['seeders'] > 2) {
bb_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders']));
} elseif ($t_data['call_seed_time'] > (TIMENOW - 86400)) {
$time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
bb_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left));
}
$ban_user_id = array();
$sql = DB()->fetch_rowset("SELECT ban_userid FROM ". BB_BANLIST ." WHERE ban_userid != 0");
$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
foreach ($sql as $row)
{
$ban_user_id[] = ','. $row['ban_userid'];
foreach ($sql as $row) {
$ban_user_id[] = ',' . $row['ban_userid'];
}
$ban_user_id = join('', $ban_user_id);
$user_list = DB()->fetch_rowset("
SELECT DISTINCT dl.user_id, u.user_opt, tr.user_id as active_dl
FROM ". BB_BT_DLSTATUS ." dl
LEFT JOIN ". BB_USERS ." u ON(u.user_id = dl.user_id)
LEFT JOIN ". BB_BT_TRACKER ." tr ON(tr.user_id = dl.user_id)
FROM " . BB_BT_DLSTATUS . " dl
LEFT JOIN " . BB_USERS . " u ON(u.user_id = dl.user_id)
LEFT JOIN " . BB_BT_TRACKER . " tr ON(tr.user_id = dl.user_id)
WHERE dl.topic_id = $topic_id
AND dl.user_status IN (". DL_STATUS_COMPLETE.", ". DL_STATUS_DOWN.")
AND dl.user_id NOT IN ({$userdata['user_id']}, ". EXCLUDED_USERS_CSV . $ban_user_id .")
AND dl.user_status IN (" . DL_STATUS_COMPLETE . ", " . DL_STATUS_DOWN . ")
AND dl.user_id NOT IN ({$userdata['user_id']}, " . EXCLUDED_USERS_CSV . $ban_user_id . ")
AND u.user_active = 1
GROUP BY dl.user_id
");
@ -49,46 +68,42 @@ $user_list = DB()->fetch_rowset("
$subject = sprintf($lang['CALLSEED_SUBJECT'], $t_data['topic_title']);
$message = sprintf($lang['CALLSEED_TEXT'], make_url(TOPIC_URL . $topic_id), $t_data['topic_title'], make_url(DOWNLOAD_URL . $t_data['attach_id']));
if ($user_list)
{
foreach ($user_list as $row)
{
if (!empty($row['active_dl'])) continue;
if ($user_list) {
foreach ($user_list as $row) {
if (!empty($row['active_dl'])) {
continue;
}
if (bf($row['user_opt'], 'user_opt', 'user_callseed'))
{
send_pm($row['user_id'], $subject, $message, BOT_UID);
}
}
}
else
{
send_pm($t_data['poster_id'], $subject, $message, BOT_UID);
if (bf($row['user_opt'], 'user_opt', 'user_callseed')) {
send_pm($row['user_id'], $subject, $message, BOT_UID);
}
}
} else {
send_pm($t_data['poster_id'], $subject, $message, BOT_UID);
}
DB()->query("UPDATE ". BB_BT_TORRENTS ." SET call_seed_time = ". TIMENOW ." WHERE topic_id = $topic_id LIMIT 1");
DB()->query("UPDATE " . BB_BT_TORRENTS . " SET call_seed_time = " . TIMENOW . " WHERE topic_id = $topic_id LIMIT 1");
meta_refresh(TOPIC_URL . $topic_id);
bb_die($lang['CALLSEED_MSG_OK']);
function topic_info ($topic_id)
function topic_info($topic_id)
{
global $lang;
global $lang;
$sql = "
$sql = "
SELECT
tor.poster_id, tor.forum_id, tor.attach_id, tor.call_seed_time,
t.topic_title, sn.seeders
FROM ". BB_BT_TORRENTS ." tor
LEFT JOIN ". BB_TOPICS ." t USING(topic_id)
LEFT JOIN ". BB_BT_TRACKER_SNAP ." sn USING(topic_id)
FROM " . BB_BT_TORRENTS . " tor
LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
LEFT JOIN " . BB_BT_TRACKER_SNAP . " sn USING(topic_id)
WHERE tor.topic_id = $topic_id
";
if (!$torrent = DB()->fetch_row($sql))
{
bb_die($lang['TOPIC_POST_NOT_EXIST']);
}
if (!$torrent = DB()->fetch_row($sql)) {
bb_die($lang['TOPIC_POST_NOT_EXIST']);
}
return $torrent;
return $torrent;
}

View file

@ -1,18 +1,55 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (isset($_REQUEST['GLOBALS'])) die();
if (isset($_REQUEST['GLOBALS'])) {
die();
}
ignore_user_abort(true);
define('TIMESTART', utime());
define('TIMENOW', time());
define('TIMENOW', time());
if (empty($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
if (empty($_SERVER['HTTP_USER_AGENT'])) $_SERVER['HTTP_USER_AGENT'] = '';
if (empty($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = '';
if (empty($_SERVER['SERVER_NAME'])) $_SERVER['SERVER_NAME'] = '';
if (empty($_SERVER['REMOTE_ADDR'])) {
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
}
if (empty($_SERVER['HTTP_USER_AGENT'])) {
$_SERVER['HTTP_USER_AGENT'] = '';
}
if (empty($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = '';
}
if (empty($_SERVER['SERVER_NAME'])) {
$_SERVER['SERVER_NAME'] = '';
}
if (!defined('BB_ROOT')) define('BB_ROOT', './');
if (!defined('IN_FORUM') && !defined('IN_TRACKER')) define('IN_FORUM', true);
if (!defined('BB_ROOT')) {
define('BB_ROOT', './');
}
if (!defined('IN_FORUM') && !defined('IN_TRACKER')) {
define('IN_FORUM', true);
}
header('X-Frame-Options: SAMEORIGIN');
@ -21,6 +58,7 @@ require(BB_ROOT . 'library/config.php');
// Load Zend Framework
use Zend\Loader\StandardAutoloader;
require(BB_ROOT . 'library/Zend/Loader/StandardAutoloader.php');
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
@ -38,29 +76,29 @@ unset($server_protocol, $server_port);
define('DBG_USER', (isset($_COOKIE[COOKIE_DBG])));
// Board/Tracker shared constants and functions
define('BB_BT_TORRENTS', 'bb_bt_torrents');
define('BB_BT_TRACKER', 'bb_bt_tracker');
define('BB_BT_TORRENTS', 'bb_bt_torrents');
define('BB_BT_TRACKER', 'bb_bt_tracker');
define('BB_BT_TRACKER_SNAP', 'bb_bt_tracker_snap');
define('BB_BT_USERS', 'bb_bt_users');
define('BB_BT_USERS', 'bb_bt_users');
define('BT_AUTH_KEY_LENGTH', 10);
define('PEER_HASH_PREFIX', 'peer_');
define('PEERS_LIST_PREFIX', 'peers_list_');
define('PEER_HASH_EXPIRE', round($bb_cfg['announce_interval'] * (0.85 * $tr_cfg['expire_factor']))); // sec
define('PEERS_LIST_EXPIRE', round($bb_cfg['announce_interval'] * 0.7)); // sec
define('PEER_HASH_PREFIX', 'peer_');
define('PEERS_LIST_PREFIX', 'peers_list_');
define('PEER_HASH_EXPIRE', round($bb_cfg['announce_interval'] * (0.85 * $tr_cfg['expire_factor']))); // sec
define('PEERS_LIST_EXPIRE', round($bb_cfg['announce_interval'] * 0.7)); // sec
define('DL_STATUS_RELEASER', -1);
define('DL_STATUS_DOWN', 0);
define('DL_STATUS_COMPLETE', 1);
define('DL_STATUS_CANCEL', 3);
define('DL_STATUS_WILL', 4);
define('DL_STATUS_DOWN', 0);
define('DL_STATUS_COMPLETE', 1);
define('DL_STATUS_CANCEL', 3);
define('DL_STATUS_WILL', 4);
define('TOR_TYPE_GOLD', 1);
define('TOR_TYPE_SILVER', 2);
define('TOR_TYPE_GOLD', 1);
define('TOR_TYPE_SILVER', 2);
define('GUEST_UID', -1);
define('BOT_UID', -746);
define('BOT_UID', -746);
/**
* Database
@ -69,10 +107,10 @@ define('BOT_UID', -746);
require(CORE_DIR . 'dbs.php');
$DBS = new DBS($bb_cfg);
function DB ($db_alias = 'db1')
function DB($db_alias = 'db1')
{
global $DBS;
return $DBS->get_db_obj($db_alias);
global $DBS;
return $DBS->get_db_obj($db_alias);
}
/**
@ -87,10 +125,10 @@ require(INC_DIR . 'datastore/common.php');
require(CORE_DIR . 'caches.php');
$CACHES = new CACHES($bb_cfg);
function CACHE ($cache_name)
function CACHE($cache_name)
{
global $CACHES;
return $CACHES->get_cache_obj($cache_name);
global $CACHES;
return $CACHES->get_cache_obj($cache_name);
}
// Common cache classes
@ -102,8 +140,8 @@ require(INC_DIR . 'cache/xcache.php');
require(INC_DIR . 'cache/file.php');
/**
* Datastore
*/
* Datastore
*/
// Common datastore classes
require(INC_DIR . 'datastore/memcache.php');
require(INC_DIR . 'datastore/sqlite.php');
@ -113,398 +151,354 @@ require(INC_DIR . 'datastore/xcache.php');
require(INC_DIR . 'datastore/file.php');
// Initialize datastore
switch ($bb_cfg['datastore_type'])
{
case 'memcache':
$datastore = new datastore_memcache($bb_cfg['cache']['memcache'], $bb_cfg['cache']['prefix']);
break;
switch ($bb_cfg['datastore_type']) {
case 'memcache':
$datastore = new datastore_memcache($bb_cfg['cache']['memcache'], $bb_cfg['cache']['prefix']);
break;
case 'sqlite':
$default_cfg = array(
'db_file_path' => $bb_cfg['cache']['db_dir'] .'datastore.sqlite.db',
'pconnect' => true,
'con_required' => true,
);
$datastore = new datastore_sqlite($default_cfg, $bb_cfg['cache']['prefix']);
break;
case 'sqlite':
$default_cfg = array(
'db_file_path' => $bb_cfg['cache']['db_dir'] . 'datastore.sqlite.db',
'pconnect' => true,
'con_required' => true,
);
$datastore = new datastore_sqlite($default_cfg, $bb_cfg['cache']['prefix']);
break;
case 'redis':
$datastore = new datastore_redis($bb_cfg['cache']['redis'], $bb_cfg['cache']['prefix']);
break;
case 'redis':
$datastore = new datastore_redis($bb_cfg['cache']['redis'], $bb_cfg['cache']['prefix']);
break;
case 'apc':
$datastore = new datastore_apc($bb_cfg['cache']['prefix']);
break;
case 'apc':
$datastore = new datastore_apc($bb_cfg['cache']['prefix']);
break;
case 'xcache':
$datastore = new datastore_xcache($bb_cfg['cache']['prefix']);
break;
case 'xcache':
$datastore = new datastore_xcache($bb_cfg['cache']['prefix']);
break;
case 'filecache':
default: $datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']);
case 'filecache':
default:
$datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']);
}
function sql_dbg_enabled ()
function sql_dbg_enabled()
{
return (SQL_DEBUG && DBG_USER && !empty($_COOKIE['sql_log']));
return (SQL_DEBUG && DBG_USER && !empty($_COOKIE['sql_log']));
}
function short_query ($sql, $esc_html = false)
function short_query($sql, $esc_html = false)
{
$max_len = 100;
$sql = str_compact($sql);
$max_len = 100;
$sql = str_compact($sql);
if (!empty($_COOKIE['sql_log_full']))
{
if (mb_strlen($sql, 'UTF-8') > $max_len)
{
$sql = mb_substr($sql, 0, 50) .' [...cut...] '. mb_substr($sql, -50);
}
}
if (!empty($_COOKIE['sql_log_full'])) {
if (mb_strlen($sql, 'UTF-8') > $max_len) {
$sql = mb_substr($sql, 0, 50) . ' [...cut...] ' . mb_substr($sql, -50);
}
}
return ($esc_html) ? htmlCHR($sql, true) : $sql;
return ($esc_html) ? htmlCHR($sql, true) : $sql;
}
// Functions
function utime ()
function utime()
{
return array_sum(explode(' ', microtime()));
return array_sum(explode(' ', microtime()));
}
function bb_log ($msg, $file_name)
function bb_log($msg, $file_name)
{
if (is_array($msg))
{
$msg = join(LOG_LF, $msg);
}
$file_name .= (LOG_EXT) ? '.'. LOG_EXT : '';
return file_write($msg, LOG_DIR . $file_name);
if (is_array($msg)) {
$msg = join(LOG_LF, $msg);
}
$file_name .= (LOG_EXT) ? '.' . LOG_EXT : '';
return file_write($msg, LOG_DIR . $file_name);
}
function file_write ($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replace_content = false)
function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replace_content = false)
{
$bytes_written = false;
$bytes_written = false;
if ($max_size && @filesize($file) >= $max_size)
{
$old_name = $file; $ext = '';
if (preg_match('#^(.+)(\.[^\\/]+)$#', $file, $matches))
{
$old_name = $matches[1]; $ext = $matches[2];
}
$new_name = $old_name .'_[old]_'. date('Y-m-d_H-i-s_') . getmypid() . $ext;
clearstatcache();
if (@file_exists($file) && @filesize($file) >= $max_size && !@file_exists($new_name))
{
@rename($file, $new_name);
}
}
if (!$fp = @fopen($file, 'ab'))
{
if ($dir_created = bb_mkdir(dirname($file)))
{
$fp = @fopen($file, 'ab');
}
}
if ($fp)
{
if ($lock)
{
@flock($fp, LOCK_EX);
}
if ($replace_content)
{
@ftruncate($fp, 0);
@fseek($fp, 0, SEEK_SET);
}
$bytes_written = @fwrite($fp, $str);
@fclose($fp);
}
if ($max_size && @filesize($file) >= $max_size) {
$old_name = $file;
$ext = '';
if (preg_match('#^(.+)(\.[^\\/]+)$#', $file, $matches)) {
$old_name = $matches[1];
$ext = $matches[2];
}
$new_name = $old_name . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . $ext;
clearstatcache();
if (@file_exists($file) && @filesize($file) >= $max_size && !@file_exists($new_name)) {
@rename($file, $new_name);
}
}
if (!$fp = @fopen($file, 'ab')) {
if ($dir_created = bb_mkdir(dirname($file))) {
$fp = @fopen($file, 'ab');
}
}
if ($fp) {
if ($lock) {
@flock($fp, LOCK_EX);
}
if ($replace_content) {
@ftruncate($fp, 0);
@fseek($fp, 0, SEEK_SET);
}
$bytes_written = @fwrite($fp, $str);
@fclose($fp);
}
return $bytes_written;
return $bytes_written;
}
function bb_mkdir ($path, $mode = 0777)
function bb_mkdir($path, $mode = 0777)
{
$old_um = umask(0);
$dir = mkdir_rec($path, $mode);
umask($old_um);
return $dir;
$old_um = umask(0);
$dir = mkdir_rec($path, $mode);
umask($old_um);
return $dir;
}
function mkdir_rec ($path, $mode)
function mkdir_rec($path, $mode)
{
if (is_dir($path))
{
return ($path !== '.' && $path !== '..') ? is_writable($path) : false;
}
else
{
return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false;
}
if (is_dir($path)) {
return ($path !== '.' && $path !== '..') ? is_writable($path) : false;
} else {
return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false;
}
}
function verify_id ($id, $length)
function verify_id($id, $length)
{
return (is_string($id) && preg_match('#^[a-zA-Z0-9]{'. $length .'}$#', $id));
return (is_string($id) && preg_match('#^[a-zA-Z0-9]{' . $length . '}$#', $id));
}
function clean_filename ($fname)
function clean_filename($fname)
{
static $s = array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ');
return str_replace($s, '_', str_compact($fname));
static $s = array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ');
return str_replace($s, '_', str_compact($fname));
}
function encode_ip ($ip)
function encode_ip($ip)
{
$d = explode('.', $ip);
return sprintf('%02x%02x%02x%02x', $d[0], $d[1], $d[2], $d[3]);
$d = explode('.', $ip);
return sprintf('%02x%02x%02x%02x', $d[0], $d[1], $d[2], $d[3]);
}
function decode_ip ($ip)
function decode_ip($ip)
{
return long2ip("0x{$ip}");
return long2ip("0x{$ip}");
}
function ip2int ($ip)
function ip2int($ip)
{
return (float) sprintf('%u', ip2long($ip)); // для совместимости с 32 битными системами
return (float)sprintf('%u', ip2long($ip)); // для совместимости с 32 битными системами
}
// long2ip( mask_ip_int(ip2int('1.2.3.4'), 24) ) = '1.2.3.255'
function mask_ip_int ($ip, $mask)
function mask_ip_int($ip, $mask)
{
$ip_int = is_numeric($ip) ? $ip : ip2int($ip);
$ip_masked = $ip_int | ((1 << (32 - $mask)) - 1);
return (float) sprintf('%u', $ip_masked);
$ip_int = is_numeric($ip) ? $ip : ip2int($ip);
$ip_masked = $ip_int | ((1 << (32 - $mask)) - 1);
return (float)sprintf('%u', $ip_masked);
}
function bb_crc32 ($str)
function bb_crc32($str)
{
return (float) sprintf('%u', crc32($str));
return (float)sprintf('%u', crc32($str));
}
function hexhex ($value)
function hexhex($value)
{
return dechex(hexdec($value));
return dechex(hexdec($value));
}
function verify_ip ($ip)
function verify_ip($ip)
{
return preg_match('#^(\d{1,3}\.){3}\d{1,3}$#', $ip);
return preg_match('#^(\d{1,3}\.){3}\d{1,3}$#', $ip);
}
function str_compact ($str)
function str_compact($str)
{
return preg_replace('#\s+#u', ' ', trim($str));
return preg_replace('#\s+#u', ' ', trim($str));
}
function make_rand_str ($len = 10)
function make_rand_str($len = 10)
{
$str = '';
while (strlen($str) < $len)
{
$str .= str_shuffle(preg_replace('#[^0-9a-zA-Z]#', '', password_hash(uniqid(mt_rand(), true), PASSWORD_BCRYPT)));
}
return substr($str, 0, $len);
$str = '';
while (strlen($str) < $len) {
$str .= str_shuffle(preg_replace('#[^0-9a-zA-Z]#', '', password_hash(uniqid(mt_rand(), true), PASSWORD_BCRYPT)));
}
return substr($str, 0, $len);
}
// bencode: based on OpenTracker
function bencode ($var)
function bencode($var)
{
if (is_string($var))
{
return strlen($var) .':'. $var;
}
else if (is_int($var))
{
return 'i'. $var .'e';
}
else if (is_float($var))
{
return 'i'. sprintf('%.0f', $var) .'e';
}
else if (is_array($var))
{
if (count($var) == 0)
{
return 'de';
}
else
{
$assoc = false;
if (is_string($var)) {
return strlen($var) . ':' . $var;
} elseif (is_int($var)) {
return 'i' . $var . 'e';
} elseif (is_float($var)) {
return 'i' . sprintf('%.0f', $var) . 'e';
} elseif (is_array($var)) {
if (count($var) == 0) {
return 'de';
} else {
$assoc = false;
foreach ($var as $key => $val)
{
if (!is_int($key))
{
$assoc = true;
break;
}
}
foreach ($var as $key => $val) {
if (!is_int($key)) {
$assoc = true;
break;
}
}
if ($assoc)
{
ksort($var, SORT_REGULAR);
$ret = 'd';
if ($assoc) {
ksort($var, SORT_REGULAR);
$ret = 'd';
foreach ($var as $key => $val)
{
$ret .= bencode($key) . bencode($val);
}
return $ret .'e';
}
else
{
$ret = 'l';
foreach ($var as $key => $val) {
$ret .= bencode($key) . bencode($val);
}
return $ret . 'e';
} else {
$ret = 'l';
foreach ($var as $val)
{
$ret .= bencode($val);
}
return $ret .'e';
}
}
}
else
{
trigger_error('bencode error: wrong data type', E_USER_ERROR);
}
foreach ($var as $val) {
$ret .= bencode($val);
}
return $ret . 'e';
}
}
} else {
trigger_error('bencode error: wrong data type', E_USER_ERROR);
}
}
function array_deep (&$var, $fn, $one_dimensional = false, $array_only = false)
function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false)
{
if (is_array($var))
{
foreach ($var as $k => $v)
{
if (is_array($v))
{
if ($one_dimensional)
{
unset($var[$k]);
}
else if ($array_only)
{
$var[$k] = $fn($v);
}
else
{
array_deep($var[$k], $fn);
}
}
else if (!$array_only)
{
$var[$k] = $fn($v);
}
}
}
else if (!$array_only)
{
$var = $fn($var);
}
if (is_array($var)) {
foreach ($var as $k => $v) {
if (is_array($v)) {
if ($one_dimensional) {
unset($var[$k]);
} elseif ($array_only) {
$var[$k] = $fn($v);
} else {
array_deep($var[$k], $fn);
}
} elseif (!$array_only) {
$var[$k] = $fn($v);
}
}
} elseif (!$array_only) {
$var = $fn($var);
}
}
function hide_bb_path ($path)
function hide_bb_path($path)
{
return ltrim(str_replace(BB_PATH, '', $path), '/\\');
return ltrim(str_replace(BB_PATH, '', $path), '/\\');
}
function sys ($param)
function sys($param)
{
switch ($param)
{
case 'la':
return function_exists('sys_getloadavg') ? join(' ', sys_getloadavg()) : 0;
break;
case 'mem':
return function_exists('memory_get_usage') ? memory_get_usage() : 0;
break;
case 'mem_peak':
return function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : 0;
break;
default:
trigger_error("invalid param: $param", E_USER_ERROR);
}
switch ($param) {
case 'la':
return function_exists('sys_getloadavg') ? join(' ', sys_getloadavg()) : 0;
break;
case 'mem':
return function_exists('memory_get_usage') ? memory_get_usage() : 0;
break;
case 'mem_peak':
return function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : 0;
break;
default:
trigger_error("invalid param: $param", E_USER_ERROR);
}
}
function ver_compare ($version1, $operator, $version2)
function ver_compare($version1, $operator, $version2)
{
return version_compare($version1, $version2, $operator);
return version_compare($version1, $version2, $operator);
}
function dbg_log ($str, $file)
function dbg_log($str, $file)
{
$dir = LOG_DIR . (defined('IN_TRACKER') ? 'dbg_tr/' : 'dbg_bb/') . date('m-d_H') .'/';
return file_write($str, $dir . $file, false, false);
$dir = LOG_DIR . (defined('IN_TRACKER') ? 'dbg_tr/' : 'dbg_bb/') . date('m-d_H') . '/';
return file_write($str, $dir . $file, false, false);
}
function log_get ($file = '', $prepend_str = false)
function log_get($file = '', $prepend_str = false)
{
log_request($file, $prepend_str, false);
log_request($file, $prepend_str, false);
}
function log_post ($file = '', $prepend_str = false)
function log_post($file = '', $prepend_str = false)
{
log_request($file, $prepend_str, true);
log_request($file, $prepend_str, true);
}
function log_request ($file = '', $prepend_str = false, $add_post = true)
function log_request($file = '', $prepend_str = false, $add_post = true)
{
global $user;
global $user;
$file = ($file) ? $file : 'req/'. date('m-d');
$str = array();
$str[] = date('m-d H:i:s');
if ($prepend_str !== false) $str[] = $prepend_str;
if (!empty($user->data)) $str[] = $user->id ."\t". html_entity_decode($user->name);
$str[] = sprintf('%-15s', $_SERVER['REMOTE_ADDR']);
$file = ($file) ? $file : 'req/' . date('m-d');
$str = array();
$str[] = date('m-d H:i:s');
if ($prepend_str !== false) {
$str[] = $prepend_str;
}
if (!empty($user->data)) {
$str[] = $user->id . "\t" . html_entity_decode($user->name);
}
$str[] = sprintf('%-15s', $_SERVER['REMOTE_ADDR']);
if (isset($_SERVER['REQUEST_URI'])) {
$str[] = $_SERVER['REQUEST_URI'];
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$str[] = $_SERVER['HTTP_USER_AGENT'];
}
if (isset($_SERVER['HTTP_REFERER'])) {
$str[] = $_SERVER['HTTP_REFERER'];
}
if (isset($_SERVER['REQUEST_URI'])) {
$str[] = $_SERVER['REQUEST_URI'];
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$str[] = $_SERVER['HTTP_USER_AGENT'];
}
if (isset($_SERVER['HTTP_REFERER'])) {
$str[] = $_SERVER['HTTP_REFERER'];
}
if (!empty($_POST) && $add_post) $str[] = "post: ". str_compact(urldecode(http_build_query($_POST)));
$str = join("\t", $str) . "\n";
bb_log($str, $file);
if (!empty($_POST) && $add_post) {
$str[] = "post: " . str_compact(urldecode(http_build_query($_POST)));
}
$str = join("\t", $str) . "\n";
bb_log($str, $file);
}
// Board init
if (defined('IN_FORUM'))
{
require(INC_DIR .'init_bb.php');
}
// Tracker init
else if (defined('IN_TRACKER'))
{
define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? intval($_GET['port']) : mt_rand(1000, 65000)));
function dummy_exit ($interval = 1800)
{
$output = bencode(array(
'interval' => (int) $interval,
'min interval' => (int) $interval,
'peers' => (string) DUMMY_PEER,
));
die($output);
}
header('Content-Type: text/plain');
header('Pragma: no-cache');
if (!defined('IN_ADMIN'))
{
// Exit if tracker is disabled via ON/OFF trigger
if (file_exists(BB_DISABLED))
{
dummy_exit(mt_rand(60, 2400));
}
}
if (defined('IN_FORUM')) {
require(INC_DIR . 'init_bb.php');
} // Tracker init
elseif (defined('IN_TRACKER')) {
define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? intval($_GET['port']) : mt_rand(1000, 65000)));
function dummy_exit($interval = 1800)
{
$output = bencode(array(
'interval' => (int)$interval,
'min interval' => (int)$interval,
'peers' => (string)DUMMY_PEER,
));
die($output);
}
header('Content-Type: text/plain');
header('Pragma: no-cache');
if (!defined('IN_ADMIN')) {
// Exit if tracker is disabled via ON/OFF trigger
if (file_exists(BB_DISABLED)) {
dummy_exit(mt_rand(60, 2400));
}
}
}

View file

@ -1,6 +1,29 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('START_CRON', true);
define('BB_ROOT', dirname ( __FILE__ ) . '/');
define('BB_ROOT', dirname(__FILE__) . '/');
require(BB_ROOT. 'common.php');
require(BB_ROOT . 'common.php');

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd">
<allow-access-from domain="*" to-ports="*" secure="false" />
<site-control permitted-cross-domain-policies="master-only" />
<cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd">
<allow-access-from domain="*" to-ports="*" secure="false"/>
<site-control permitted-cross-domain-policies="master-only"/>
</cross-domain-policy>

277
dl.php
View file

@ -1,14 +1,37 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_SCRIPT', 'dl');
define('NO_GZIP', true);
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(ATTACH_DIR .'attachment_mod.php');
define('BB_ROOT', './');
require(BB_ROOT . 'common.php');
require(ATTACH_DIR . 'attachment_mod.php');
$datastore->enqueue(array(
'attach_extensions',
'attach_extensions',
));
$download_id = request_var('id', 0);
@ -17,62 +40,53 @@ $thumbnail = request_var('thumb', 0);
// Send file to browser
function send_file_to_browser($attachment, $upload_dir)
{
global $bb_cfg, $lang, $userdata;
global $bb_cfg, $lang, $userdata;
$filename = ($upload_dir == '') ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
$filename = ($upload_dir == '') ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
$gotit = false;
$gotit = false;
if (@!file_exists(@amod_realpath($filename)))
{
bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename. "<br /><br />" .$lang['TOR_NOT_FOUND']);
}
else
{
$gotit = true;
}
if (@!file_exists(@amod_realpath($filename))) {
bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']);
} else {
$gotit = true;
}
// Correct the mime type - we force application/octet-stream for all files, except images
// Please do not change this, it is a security precaution
if (!strstr($attachment['mimetype'], 'image'))
{
$attachment['mimetype'] = 'application/octet-stream';
}
// Correct the mime type - we force application/octet-stream for all files, except images
// Please do not change this, it is a security precaution
if (!strstr($attachment['mimetype'], 'image')) {
$attachment['mimetype'] = 'application/octet-stream';
}
//bt
if (!(isset($_GET['original']) && !IS_USER))
{
include(INC_DIR .'functions_torrent.php');
send_torrent_with_passkey($filename);
}
//bt
if (!(isset($_GET['original']) && !IS_USER)) {
include(INC_DIR . 'functions_torrent.php');
send_torrent_with_passkey($filename);
}
// Now the tricky part... let's dance
header('Pragma: public');
$real_filename = clean_filename(basename($attachment['real_filename']));
$mimetype = $attachment['mimetype'].';';
$charset = "charset={$bb_cfg['lang'][$userdata['user_lang']]['encoding']};";
// Now the tricky part... let's dance
header('Pragma: public');
$real_filename = clean_filename(basename($attachment['real_filename']));
$mimetype = $attachment['mimetype'] . ';';
$charset = "charset={$bb_cfg['lang'][$userdata['user_lang']]['encoding']};";
// Send out the Headers
header("Content-Type: $mimetype $charset name=\"$real_filename\"");
header("Content-Disposition: inline; filename=\"$real_filename\"");
unset($real_filename);
// Send out the Headers
header("Content-Type: $mimetype $charset name=\"$real_filename\"");
header("Content-Disposition: inline; filename=\"$real_filename\"");
unset($real_filename);
// Now send the File Contents to the Browser
if ($gotit)
{
$size = @filesize($filename);
if ($size)
{
header("Content-length: $size");
}
readfile($filename);
}
else
{
bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename. "<br /><br />" .$lang['TOR_NOT_FOUND']);
}
// Now send the File Contents to the Browser
if ($gotit) {
$size = @filesize($filename);
if ($size) {
header("Content-length: $size");
}
readfile($filename);
} else {
bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']);
}
exit;
exit;
}
//
@ -82,26 +96,22 @@ $user->session_start();
set_die_append_msg();
if (!$download_id)
{
bb_die($lang['NO_ATTACHMENT_SELECTED']);
if (!$download_id) {
bb_die($lang['NO_ATTACHMENT_SELECTED']);
}
if ($attach_config['disable_mod'] && !IS_ADMIN)
{
bb_die($lang['ATTACHMENT_FEATURE_DISABLED']);
if ($attach_config['disable_mod'] && !IS_ADMIN) {
bb_die($lang['ATTACHMENT_FEATURE_DISABLED']);
}
$sql = 'SELECT * FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int) $download_id;
$sql = 'SELECT * FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int)$download_id;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachment information #1');
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachment information #1');
}
if (!($attachment = DB()->sql_fetchrow($result)))
{
bb_die($lang['ERROR_NO_ATTACHMENT']);
if (!($attachment = DB()->sql_fetchrow($result))) {
bb_die($lang['ERROR_NO_ATTACHMENT']);
}
$attachment['physical_filename'] = basename($attachment['physical_filename']);
@ -111,48 +121,42 @@ DB()->sql_freeresult($result);
// get forum_id for attachment authorization or private message authorization
$authorised = false;
$sql = 'SELECT * FROM ' . BB_ATTACHMENTS . ' WHERE attach_id = ' . (int) $attachment['attach_id'];
$sql = 'SELECT * FROM ' . BB_ATTACHMENTS . ' WHERE attach_id = ' . (int)$attachment['attach_id'];
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachment information #2');
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachment information #2');
}
$auth_pages = DB()->sql_fetchrowset($result);
$num_auth_pages = DB()->num_rows($result);
for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++)
{
$auth_pages[$i]['post_id'] = intval($auth_pages[$i]['post_id']);
for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++) {
$auth_pages[$i]['post_id'] = intval($auth_pages[$i]['post_id']);
if ($auth_pages[$i]['post_id'] != 0)
{
$sql = 'SELECT forum_id, topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int) $auth_pages[$i]['post_id'];
if ($auth_pages[$i]['post_id'] != 0) {
$sql = 'SELECT forum_id, topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int)$auth_pages[$i]['post_id'];
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query post information');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query post information');
}
$row = DB()->sql_fetchrow($result);
$row = DB()->sql_fetchrow($result);
$topic_id = $row['topic_id'];
$forum_id = $row['forum_id'];
$topic_id = $row['topic_id'];
$forum_id = $row['forum_id'];
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata);
set_die_append_msg($forum_id, $topic_id);
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata);
set_die_append_msg($forum_id, $topic_id);
if ($is_auth['auth_download'])
{
$authorised = TRUE;
}
}
if ($is_auth['auth_download']) {
$authorised = true;
}
}
}
if (!$authorised)
{
bb_die($lang['SORRY_AUTH_VIEW_ATTACH']);
if (!$authorised) {
bb_die($lang['SORRY_AUTH_VIEW_ATTACH']);
}
$datastore->rm('cat_forums');
@ -163,67 +167,58 @@ $datastore->rm('cat_forums');
$rows = get_extension_informations();
$num_rows = count($rows);
for ($i = 0; $i < $num_rows; $i++)
{
$extension = strtolower(trim($rows[$i]['extension']));
$allowed_extensions[] = $extension;
$download_mode[$extension] = $rows[$i]['download_mode'];
for ($i = 0; $i < $num_rows; $i++) {
$extension = strtolower(trim($rows[$i]['extension']));
$allowed_extensions[] = $extension;
$download_mode[$extension] = $rows[$i]['download_mode'];
}
// Disallowed
if (!in_array($attachment['extension'], $allowed_extensions) && !IS_ADMIN)
{
bb_die(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
if (!in_array($attachment['extension'], $allowed_extensions) && !IS_ADMIN) {
bb_die(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
}
$download_mode = intval($download_mode[$attachment['extension']]);
if ($thumbnail)
{
$attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
if ($thumbnail) {
$attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
}
// Update download count
if (!$thumbnail)
{
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET download_count = download_count + 1 WHERE attach_id = ' . (int) $attachment['attach_id'];
if (!$thumbnail) {
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET download_count = download_count + 1 WHERE attach_id = ' . (int)$attachment['attach_id'];
if (!DB()->sql_query($sql))
{
bb_die('Could not update attachment download count');
}
if (!DB()->sql_query($sql)) {
bb_die('Could not update attachment download count');
}
}
// Determine the 'presenting'-method
if ($download_mode == PHYSICAL_LINK)
{
$url = make_url($upload_dir . '/' . $attachment['physical_filename']);
header('Location: ' . $url);
exit;
if ($download_mode == PHYSICAL_LINK) {
$url = make_url($upload_dir . '/' . $attachment['physical_filename']);
header('Location: ' . $url);
exit;
} else {
if (IS_GUEST && !bb_captcha('check')) {
global $template;
$redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/');
$message = '<form action="' . DOWNLOAD_URL . $attachment['attach_id'] . '" method="post">';
$message .= $lang['CAPTCHA'] . ':';
$message .= '<div class="mrg_10" align="center">' . bb_captcha('get') . '</div>';
$message .= '<input type="hidden" name="redirect_url" value="' . $redirect_url . '" />';
$message .= '<input type="submit" class="bold" value="' . $lang['SUBMIT'] . '" /> &nbsp;';
$message .= '<input type="button" class="bold" value="' . $lang['GO_BACK'] . '" onclick="document.location.href = \'' . $redirect_url . '\';" />';
$message .= '</form>';
$template->assign_vars(array(
'ERROR_MESSAGE' => $message,
));
require(PAGE_HEADER);
require(PAGE_FOOTER);
}
send_file_to_browser($attachment, $upload_dir);
exit;
}
else
{
if (IS_GUEST && !bb_captcha('check'))
{
global $template;
$redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/');
$message = '<form action="'. DOWNLOAD_URL . $attachment['attach_id'] .'" method="post">';
$message .= $lang['CAPTCHA'].':';
$message .= '<div class="mrg_10" align="center">'. bb_captcha('get') .'</div>';
$message .= '<input type="hidden" name="redirect_url" value="'. $redirect_url .'" />';
$message .= '<input type="submit" class="bold" value="'. $lang['SUBMIT'] .'" /> &nbsp;';
$message .= '<input type="button" class="bold" value="'. $lang['GO_BACK'] .'" onclick="document.location.href = \''. $redirect_url .'\';" />';
$message .= '</form>';
$template->assign_vars(array(
'ERROR_MESSAGE' => $message,
));
require(PAGE_HEADER);
require(PAGE_FOOTER);
}
send_file_to_browser($attachment, $upload_dir);
exit;
}

View file

@ -1,56 +1,66 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_SCRIPT', 'dl_list');
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
$forum_id = isset($_REQUEST[POST_FORUM_URL]) ? (int) $_REQUEST[POST_FORUM_URL] : 0;
$topic_id = isset($_REQUEST[POST_TOPIC_URL]) ? (int) $_REQUEST[POST_TOPIC_URL] : 0;
$mode = isset($_REQUEST['mode']) ? (string) $_REQUEST['mode'] : '';
$forum_id = isset($_REQUEST[POST_FORUM_URL]) ? (int)$_REQUEST[POST_FORUM_URL] : 0;
$topic_id = isset($_REQUEST[POST_TOPIC_URL]) ? (int)$_REQUEST[POST_TOPIC_URL] : 0;
$mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
$confirmed = isset($_POST['confirm']);
// Get new DL-status
if ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')
{
if (isset($_POST['dl_set_will']))
{
$new_dl_status = DL_STATUS_WILL;
$dl_key = 'dlw';
}
elseif (isset($_POST['dl_set_down']))
{
$new_dl_status = DL_STATUS_DOWN;
$dl_key = 'dld';
}
elseif (isset($_POST['dl_set_complete']))
{
$new_dl_status = DL_STATUS_COMPLETE;
$dl_key = 'dlc';
}
elseif (isset($_POST['dl_set_cancel']))
{
$new_dl_status = DL_STATUS_CANCEL;
$dl_key = 'dla';
}
else
{
bb_die('Invalid download status');
}
if ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status') {
if (isset($_POST['dl_set_will'])) {
$new_dl_status = DL_STATUS_WILL;
$dl_key = 'dlw';
} elseif (isset($_POST['dl_set_down'])) {
$new_dl_status = DL_STATUS_DOWN;
$dl_key = 'dld';
} elseif (isset($_POST['dl_set_complete'])) {
$new_dl_status = DL_STATUS_COMPLETE;
$dl_key = 'dlc';
} elseif (isset($_POST['dl_set_cancel'])) {
$new_dl_status = DL_STATUS_CANCEL;
$dl_key = 'dla';
} else {
bb_die('Invalid download status');
}
}
// Define redirect URL
$full_url = isset($_POST['full_url']) ? str_replace('&amp;', '&', htmlspecialchars($_POST['full_url'])) : '';
if (isset($_POST['redirect_type']) && $_POST['redirect_type'] == 'search')
{
$redirect_type = "search.php";
$redirect = ($full_url) ? $full_url : "$dl_key=1";
}
else
{
$redirect_type = (!$topic_id) ? "viewforum.php" : "viewtopic.php";
$redirect = ($full_url) ? $full_url : ((!$topic_id) ? POST_FORUM_URL ."=$forum_id" : POST_TOPIC_URL ."=$topic_id");
if (isset($_POST['redirect_type']) && $_POST['redirect_type'] == 'search') {
$redirect_type = "search.php";
$redirect = ($full_url) ? $full_url : "$dl_key=1";
} else {
$redirect_type = (!$topic_id) ? "viewforum.php" : "viewtopic.php";
$redirect = ($full_url) ? $full_url : ((!$topic_id) ? POST_FORUM_URL . "=$forum_id" : POST_TOPIC_URL . "=$topic_id");
}
// Start session management
@ -59,104 +69,88 @@ $user->session_start();
set_die_append_msg();
// Check if user logged in
if (!$userdata['session_logged_in'])
{
redirect(LOGIN_URL . "?redirect=$redirect_type&$redirect");
if (!$userdata['session_logged_in']) {
redirect(LOGIN_URL . "?redirect=$redirect_type&$redirect");
}
// Check if user did not confirm
if (isset($_POST['cancel']) && $_POST['cancel'])
{
redirect("$redirect_type?$redirect");
if (isset($_POST['cancel']) && $_POST['cancel']) {
redirect("$redirect_type?$redirect");
}
// Delete DL-list
if ($mode == 'dl_delete' && $topic_id)
{
if (!IS_ADMIN)
{
$sql = "SELECT forum_id FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1";
if ($mode == 'dl_delete' && $topic_id) {
if (!IS_ADMIN) {
$sql = "SELECT forum_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1";
if (!$row = DB()->sql_fetchrow(DB()->sql_query($sql)))
{
bb_die('Could not obtain forum_id for this topic');
}
if (!$row = DB()->sql_fetchrow(DB()->sql_query($sql))) {
bb_die('Could not obtain forum_id for this topic');
}
$is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
$is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
if (!$is_auth['auth_mod'])
{
bb_die($lang['NOT_MODERATOR']);
}
}
if (!$is_auth['auth_mod']) {
bb_die($lang['NOT_MODERATOR']);
}
}
if (!$confirmed)
{
$hidden_fields = array(
't' => $topic_id,
'mode' => 'dl_delete',
);
if (!$confirmed) {
$hidden_fields = array(
't' => $topic_id,
'mode' => 'dl_delete',
);
print_confirmation(array(
'QUESTION' => $lang['DL_LIST_DEL_CONFIRM'],
'FORM_ACTION' => 'dl_list.php',
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
}
print_confirmation(array(
'QUESTION' => $lang['DL_LIST_DEL_CONFIRM'],
'FORM_ACTION' => 'dl_list.php',
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
}
clear_dl_list($topic_id);
redirect("$redirect_type?$redirect");
clear_dl_list($topic_id);
redirect("$redirect_type?$redirect");
}
// Update DL status
$req_topics_ary = $topics_ary = array();
// Get topics selected by user
if ($mode == 'set_topics_dl_status')
{
if (!isset($_POST['dl_topics_id_list']) || !is_array($_POST['dl_topics_id_list']))
{
bb_die($lang['NONE_SELECTED']);
}
if ($mode == 'set_topics_dl_status') {
if (!isset($_POST['dl_topics_id_list']) || !is_array($_POST['dl_topics_id_list'])) {
bb_die($lang['NONE_SELECTED']);
}
foreach ($_POST['dl_topics_id_list'] as $topic_id)
{
$req_topics_ary[] = (int) $topic_id;
}
}
elseif ($mode == 'set_dl_status')
{
$req_topics_ary[] = (int) $topic_id;
foreach ($_POST['dl_topics_id_list'] as $topic_id) {
$req_topics_ary[] = (int)$topic_id;
}
} elseif ($mode == 'set_dl_status') {
$req_topics_ary[] = (int)$topic_id;
}
// Get existing topics
if ($req_topics_sql = join(',', $req_topics_ary))
{
$sql = "SELECT topic_id FROM ". BB_TOPICS ." WHERE topic_id IN($req_topics_sql)";
if ($req_topics_sql = join(',', $req_topics_ary)) {
$sql = "SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_id IN($req_topics_sql)";
foreach (DB()->fetch_rowset($sql) as $row)
{
$topics_ary[] = $row['topic_id'];
}
foreach (DB()->fetch_rowset($sql) as $row) {
$topics_ary[] = $row['topic_id'];
}
}
if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status'))
{
$new_dlstatus_ary = array();
if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')) {
$new_dlstatus_ary = array();
foreach ($topics_ary as $topic_id)
{
$new_dlstatus_ary[] = array(
'user_id' => (int) $user->id,
'topic_id' => (int) $topic_id,
'user_status' => (int) $new_dl_status,
);
}
$new_dlstatus_sql = DB()->build_array('MULTI_INSERT', $new_dlstatus_ary);
foreach ($topics_ary as $topic_id) {
$new_dlstatus_ary[] = array(
'user_id' => (int)$user->id,
'topic_id' => (int)$topic_id,
'user_status' => (int)$new_dl_status,
);
}
$new_dlstatus_sql = DB()->build_array('MULTI_INSERT', $new_dlstatus_ary);
DB()->query("REPLACE INTO ". BB_BT_DLSTATUS ." $new_dlstatus_sql");
DB()->query("REPLACE INTO " . BB_BT_DLSTATUS . " $new_dlstatus_sql");
redirect("$redirect_type?$redirect");
redirect("$redirect_type?$redirect");
}
redirect("index.php");
redirect("index.php");

127
feed.php
View file

@ -1,68 +1,85 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_SCRIPT', 'feed');
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
$user->session_start(array('req_login' => true));
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
$type = isset($_POST['type']) ? $_POST['type'] : '';
$id = isset($_POST['id']) ? $_POST['id'] : 0;
$id = isset($_POST['id']) ? $_POST['id'] : 0;
$timecheck = TIMENOW - 600;
if (!$mode) bb_simple_die($lang['ATOM_NO_MODE']);
if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0)
{
if ($type == 'f')
{
// Check if the user has actually sent a forum ID
$sql = "SELECT allow_reg_tracker, forum_name FROM ". BB_FORUMS ." WHERE forum_id = $id LIMIT 1";
if (!$forum_data = DB()->fetch_row($sql))
{
if ($id == 0)
{
$forum_data = array();
}
else bb_simple_die($lang['ATOM_ERROR'].' #1');
}
if (file_exists($bb_cfg['atom']['path'] .'/f/'. $id .'.atom') && filemtime($bb_cfg['atom']['path'] .'/f/'. $id .'.atom') > $timecheck)
{
redirect($bb_cfg['atom']['url'] .'/f/'. $id .'.atom');
}
else
{
require_once(INC_DIR .'functions_atom.php');
if (update_forum_feed($id, $forum_data)) redirect($bb_cfg['atom']['url'] .'/f/'. $id .'.atom');
else bb_simple_die($lang['ATOM_NO_FORUM']);
}
}
if ($type == 'u')
{
// Check if the user has actually sent a user ID
if ($id < 1)
{
bb_simple_die($lang['ATOM_ERROR'].' #2');
}
if (!$username = get_username($id))
{
bb_simple_die($lang['ATOM_ERROR'].' #3');
}
if (file_exists($bb_cfg['atom']['path'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom') && filemtime($bb_cfg['atom']['path'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom') > $timecheck)
{
redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom');
}
else
{
require_once(INC_DIR .'functions_atom.php');
if (update_user_feed($id, $username)) redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom');
else bb_simple_die($lang['ATOM_NO_USER']);
}
}
if (!$mode) {
bb_simple_die($lang['ATOM_NO_MODE']);
}
if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0) {
if ($type == 'f') {
// Check if the user has actually sent a forum ID
$sql = "SELECT allow_reg_tracker, forum_name FROM " . BB_FORUMS . " WHERE forum_id = $id LIMIT 1";
if (!$forum_data = DB()->fetch_row($sql)) {
if ($id == 0) {
$forum_data = array();
} else {
bb_simple_die($lang['ATOM_ERROR'] . ' #1');
}
}
if (file_exists($bb_cfg['atom']['path'] . '/f/' . $id . '.atom') && filemtime($bb_cfg['atom']['path'] . '/f/' . $id . '.atom') > $timecheck) {
redirect($bb_cfg['atom']['url'] . '/f/' . $id . '.atom');
} else {
require_once(INC_DIR . 'functions_atom.php');
if (update_forum_feed($id, $forum_data)) {
redirect($bb_cfg['atom']['url'] . '/f/' . $id . '.atom');
} else {
bb_simple_die($lang['ATOM_NO_FORUM']);
}
}
}
if ($type == 'u') {
// Check if the user has actually sent a user ID
if ($id < 1) {
bb_simple_die($lang['ATOM_ERROR'] . ' #2');
}
if (!$username = get_username($id)) {
bb_simple_die($lang['ATOM_ERROR'] . ' #3');
}
if (file_exists($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') && filemtime($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom') > $timecheck) {
redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom');
} else {
require_once(INC_DIR . 'functions_atom.php');
if (update_user_feed($id, $username)) {
redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . ($id % 100) . '/' . $id . '.atom');
} else {
bb_simple_die($lang['ATOM_NO_USER']);
}
}
}
} else {
bb_simple_die($lang['ATOM_ERROR'] . ' #4');
}
else
{
bb_simple_die($lang['ATOM_ERROR'].' #4');
}

970
group.php

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,33 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_SCRIPT', 'group_edit');
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(INC_DIR .'functions_group.php');
require(BB_ROOT . 'common.php');
require(INC_DIR . 'functions_group.php');
$page_cfg['include_bbcode_js'] = true;
@ -17,98 +40,81 @@ $is_moderator = false;
$submit = !empty($_POST['submit']);
if ($group_id)
{
if (!$group_info = get_group_data($group_id))
{
bb_die($lang['GROUP_NOT_EXIST']);
}
if (!$group_info['group_id'] || !$group_info['group_moderator'] || !$group_info['moderator_name'])
{
bb_die("Invalid group data [group_id: $group_id]");
}
$is_moderator = ($userdata['user_id'] == $group_info['group_moderator'] || IS_ADMIN);
if ($group_id) {
if (!$group_info = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
if (!$group_info['group_id'] || !$group_info['group_moderator'] || !$group_info['moderator_name']) {
bb_die("Invalid group data [group_id: $group_id]");
}
$is_moderator = ($userdata['user_id'] == $group_info['group_moderator'] || IS_ADMIN);
}
if ($is_moderator)
{
// TODO Admin panel, some tasty features
if ($is_moderator) {
// TODO Admin panel, some tasty features
// Avatar
if ($submit)
{
if (!empty($_FILES['avatar']['name']) && $bb_cfg['group_avatars']['up_allowed'])
{
require(INC_DIR .'functions_upload.php');
$upload = new upload_common();
// Avatar
if ($submit) {
if (!empty($_FILES['avatar']['name']) && $bb_cfg['group_avatars']['up_allowed']) {
require(INC_DIR . 'functions_upload.php');
$upload = new upload_common();
if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) AND $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id'])))
{
$avatar_ext_id = (int) $upload->file_ext_id;
}
else
{
bb_die(implode($upload->errors));
}
if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) and $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id']))) {
$avatar_ext_id = (int)$upload->file_ext_id;
} else {
bb_die(implode($upload->errors));
}
DB()->query("UPDATE ". BB_GROUPS ." SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id LIMIT 1");
}
}
DB()->query("UPDATE " . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id LIMIT 1");
}
}
$group_type = '';
if ($group_info['group_type'] == GROUP_OPEN)
{
$group_type = $lang['GROUP_OPEN'];
}
elseif ($group_info['group_type'] == GROUP_CLOSED)
{
$group_type = $lang['GROUP_CLOSED'];
}
elseif ($group_info['group_type'] == GROUP_HIDDEN)
{
$group_type = $lang['GROUP_HIDDEN'];
}
$group_type = '';
if ($group_info['group_type'] == GROUP_OPEN) {
$group_type = $lang['GROUP_OPEN'];
} elseif ($group_info['group_type'] == GROUP_CLOSED) {
$group_type = $lang['GROUP_CLOSED'];
} elseif ($group_info['group_type'] == GROUP_HIDDEN) {
$group_type = $lang['GROUP_HIDDEN'];
}
$s_hidden_fields = '<input type="hidden" name="'. POST_GROUPS_URL .'" value="'. $group_id .'" />';
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
$template->assign_vars(array(
'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
'GROUP_NAME' => htmlCHR($group_info['group_name']),
'GROUP_ID' => $group_id,
'GROUP_DESCRIPTION' => htmlCHR($group_info['group_description']),
'GROUP_SIGNATURE' => htmlCHR($group_info['group_signature']),
'U_GROUP_URL' => GROUP_URL . $group_id,
'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
'GROUP_TYPE' => $group_type,
'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? ' checked="checked"' : '',
'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? ' checked="checked"' : '',
'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? ' checked="checked"' : '',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id",
$template->assign_vars(array(
'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
'GROUP_NAME' => htmlCHR($group_info['group_name']),
'GROUP_ID' => $group_id,
'GROUP_DESCRIPTION' => htmlCHR($group_info['group_description']),
'GROUP_SIGNATURE' => htmlCHR($group_info['group_signature']),
'U_GROUP_URL' => GROUP_URL . $group_id,
'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
'GROUP_TYPE' => $group_type,
'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
'S_GROUP_OPEN_CHECKED' => ($group_info['group_type'] == GROUP_OPEN) ? ' checked="checked"' : '',
'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? ' checked="checked"' : '',
'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? ' checked="checked"' : '',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id",
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))),
'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
));
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))),
'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
));
$template->set_filenames(array('body' => 'group_edit.tpl'));
$template->assign_vars(array('PAGE_TITLE' => $lang['GROUP_CONFIGURATION']));
$template->set_filenames(array('body' => 'group_edit.tpl'));
$template->assign_vars(array('PAGE_TITLE' => $lang['GROUP_CONFIGURATION']));
require(PAGE_HEADER);
require(PAGE_HEADER);
$template->pparse('body');
$template->pparse('body');
require(PAGE_FOOTER);
require(PAGE_FOOTER);
} else {
$redirect = 'index.php';
if ($group_id) {
$redirect = GROUP_URL . $group_id;
}
redirect($redirect);
}
else
{
$redirect = 'index.php';
if ($group_id)
{
$redirect = GROUP_URL . $group_id;
}
redirect($redirect);
}

554
index.php
View file

@ -1,37 +1,58 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('IN_FORUM', true);
define('BB_SCRIPT', 'index');
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
$page_cfg['load_tpl_vars'] = array(
'post_icons',
'post_icons',
);
$show_last_topic = true;
$show_last_topic = true;
$last_topic_max_len = 28;
$show_online_users = true;
$show_subforums = true;
$show_online_users = true;
$show_subforums = true;
$datastore->enqueue(array(
'stats',
'moderators',
'stats',
'moderators',
));
if ($bb_cfg['show_latest_news'])
{
$datastore->enqueue('latest_news');
if ($bb_cfg['show_latest_news']) {
$datastore->enqueue('latest_news');
}
if ($bb_cfg['show_network_news'])
{
$datastore->enqueue('network_news');
if ($bb_cfg['show_network_news']) {
$datastore->enqueue('network_news');
}
// Init userdata
$user->session_start();
// Init main vars
$viewcat = isset($_GET['c']) ? (int) $_GET['c'] : 0;
$viewcat = isset($_GET['c']) ? (int)$_GET['c'] : 0;
$lastvisit = (IS_GUEST) ? TIMENOW : $userdata['user_lastvisit'];
// Caching output
@ -39,28 +60,26 @@ $req_page = 'index_page';
$req_page .= ($viewcat) ? "_c{$viewcat}" : '';
define('REQUESTED_PAGE', $req_page);
caching_output(IS_GUEST, 'send', REQUESTED_PAGE .'_guest_'. $bb_cfg['default_lang']);
caching_output(IS_GUEST, 'send', REQUESTED_PAGE . '_guest_' . $bb_cfg['default_lang']);
$hide_cat_opt = isset($user->opt_js['h_cat']) ? (string) $user->opt_js['h_cat'] : 0;
$hide_cat_opt = isset($user->opt_js['h_cat']) ? (string)$user->opt_js['h_cat'] : 0;
$hide_cat_user = array_flip(explode('-', $hide_cat_opt));
$showhide = isset($_GET['sh']) ? (int) $_GET['sh'] : 0;
$showhide = isset($_GET['sh']) ? (int)$_GET['sh'] : 0;
// Topics read tracks
$tracking_topics = get_tracks('topic');
$tracking_forums = get_tracks('forum');
// Statistics
if (!$stats = $datastore->get('stats'))
{
$datastore->update('stats');
$stats = $datastore->get('stats');
if (!$stats = $datastore->get('stats')) {
$datastore->update('stats');
$stats = $datastore->get('stats');
}
// Forums data
if (!$forums = $datastore->get('cat_forums'))
{
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$cat_title_html = $forums['cat_title_html'];
$forum_name_html = $forums['forum_name_html'];
@ -70,9 +89,8 @@ $excluded_forums_csv = $user->get_excluded_forums(AUTH_VIEW);
$only_new = $user->opt_js['only_new'];
// Validate requested category id
if ($viewcat AND !$viewcat =& $forums['c'][$viewcat]['cat_id'])
{
redirect("index.php");
if ($viewcat and !$viewcat =& $forums['c'][$viewcat]['cat_id']) {
redirect("index.php");
}
// Forums
@ -106,96 +124,78 @@ $sql = "
t.topic_id AS last_topic_id, t.topic_title AS last_topic_title,
u.user_id AS last_post_user_id, u.user_rank AS last_post_user_rank,
IF(p.poster_id = $anon, p.post_username, u.username) AS last_post_username
FROM ". BB_CATEGORIES ." c
INNER JOIN ". BB_FORUMS ." f ON($forums_join_sql)
$join_p_type ". BB_POSTS ." p ON($posts_join_sql)
$join_t_type ". BB_TOPICS ." t ON($topics_join_sql)
LEFT JOIN ". BB_USERS ." u ON(u.user_id = p.poster_id)
FROM " . BB_CATEGORIES . " c
INNER JOIN " . BB_FORUMS . " f ON($forums_join_sql)
$join_p_type " . BB_POSTS . " p ON($posts_join_sql)
$join_t_type " . BB_TOPICS . " t ON($topics_join_sql)
LEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id)
ORDER BY c.cat_order, f.forum_order
";
$replace_in_parent = array(
'last_post_id',
'last_post_time',
'last_post_user_id',
'last_post_username',
'last_post_user_rank',
'last_topic_title',
'last_topic_id',
'last_post_id',
'last_post_time',
'last_post_user_id',
'last_post_username',
'last_post_user_rank',
'last_topic_title',
'last_topic_id',
);
$cache_name = 'index_sql_' . md5($sql);
if (!$cat_forums = CACHE('bb_cache')->get($cache_name))
{
$cat_forums = array();
foreach (DB()->fetch_rowset($sql) as $row)
{
if (!$cat_id = $row['cat_id'] OR !$forum_id = $row['forum_id'])
{
continue;
}
if (!$cat_forums = CACHE('bb_cache')->get($cache_name)) {
$cat_forums = array();
foreach (DB()->fetch_rowset($sql) as $row) {
if (!$cat_id = $row['cat_id'] or !$forum_id = $row['forum_id']) {
continue;
}
if ($parent_id = $row['forum_parent'])
{
if (!$parent =& $cat_forums[$cat_id]['f'][$parent_id])
{
$parent = $forums['f'][$parent_id];
$parent['last_post_time'] = 0;
}
if ($row['last_post_time'] > $parent['last_post_time'])
{
foreach ($replace_in_parent as $key)
{
$parent[$key] = $row[$key];
}
}
if ($show_subforums && $row['show_on_index'])
{
$parent['last_sf_id'] = $forum_id;
}
else
{
continue;
}
}
else
{
$f =& $forums['f'][$forum_id];
$row['forum_desc'] = $f['forum_desc'];
$row['forum_posts'] = $f['forum_posts'];
$row['forum_topics'] = $f['forum_topics'];
}
$cat_forums[$cat_id]['f'][$forum_id] = $row;
}
CACHE('bb_cache')->set($cache_name, $cat_forums, 180);
unset($row, $forums);
$datastore->rm('cat_forums');
if ($parent_id = $row['forum_parent']) {
if (!$parent =& $cat_forums[$cat_id]['f'][$parent_id]) {
$parent = $forums['f'][$parent_id];
$parent['last_post_time'] = 0;
}
if ($row['last_post_time'] > $parent['last_post_time']) {
foreach ($replace_in_parent as $key) {
$parent[$key] = $row[$key];
}
}
if ($show_subforums && $row['show_on_index']) {
$parent['last_sf_id'] = $forum_id;
} else {
continue;
}
} else {
$f =& $forums['f'][$forum_id];
$row['forum_desc'] = $f['forum_desc'];
$row['forum_posts'] = $f['forum_posts'];
$row['forum_topics'] = $f['forum_topics'];
}
$cat_forums[$cat_id]['f'][$forum_id] = $row;
}
CACHE('bb_cache')->set($cache_name, $cat_forums, 180);
unset($row, $forums);
$datastore->rm('cat_forums');
}
// Obtain list of moderators
$moderators = array();
if (!$mod = $datastore->get('moderators'))
{
$datastore->update('moderators');
$mod = $datastore->get('moderators');
if (!$mod = $datastore->get('moderators')) {
$datastore->update('moderators');
$mod = $datastore->get('moderators');
}
if (!empty($mod))
{
foreach ($mod['mod_users'] as $forum_id => $user_ids)
{
foreach ($user_ids as $user_id)
{
$moderators[$forum_id][] = '<a href="'. PROFILE_URL . $user_id .'">'. $mod['name_users'][$user_id] .'</a>';
}
}
foreach ($mod['mod_groups'] as $forum_id => $group_ids)
{
foreach ($group_ids as $group_id)
{
$moderators[$forum_id][] = '<a href="'. GROUP_URL . $group_id .'">'. $mod['name_groups'][$group_id] .'</a>';
}
}
if (!empty($mod)) {
foreach ($mod['mod_users'] as $forum_id => $user_ids) {
foreach ($user_ids as $user_id) {
$moderators[$forum_id][] = '<a href="' . PROFILE_URL . $user_id . '">' . $mod['name_users'][$user_id] . '</a>';
}
}
foreach ($mod['mod_groups'] as $forum_id => $group_ids) {
foreach ($group_ids as $group_id) {
$moderators[$forum_id][] = '<a href="' . GROUP_URL . $group_id . '">' . $mod['name_groups'][$group_id] . '</a>';
}
}
}
unset($mod);
@ -203,229 +203,209 @@ $datastore->rm('moderators');
// Build index page
$forums_count = 0;
foreach ($cat_forums as $cid => $c)
{
$template->assign_block_vars('h_c', array(
'H_C_ID' => $cid,
'H_C_TITLE' => $cat_title_html[$cid],
'H_C_CHEKED' => in_array($cid, preg_split("/[-]+/", $hide_cat_opt)) ? 'checked' : '',
));
foreach ($cat_forums as $cid => $c) {
$template->assign_block_vars('h_c', array(
'H_C_ID' => $cid,
'H_C_TITLE' => $cat_title_html[$cid],
'H_C_CHEKED' => in_array($cid, preg_split("/[-]+/", $hide_cat_opt)) ? 'checked' : '',
));
$template->assign_vars(array(
'H_C_AL_MESS' => ($hide_cat_opt && !$showhide) ? true : false,
));
$template->assign_vars(array(
'H_C_AL_MESS' => ($hide_cat_opt && !$showhide) ? true : false,
));
if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat)
{
continue;
}
if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) {
continue;
}
$template->assign_block_vars('c', array(
'CAT_ID' => $cid,
'CAT_TITLE' => $cat_title_html[$cid],
'U_VIEWCAT' => CAT_URL . $cid,
));
$template->assign_block_vars('c', array(
'CAT_ID' => $cid,
'CAT_TITLE' => $cat_title_html[$cid],
'U_VIEWCAT' => CAT_URL . $cid,
));
foreach ($c['f'] as $fid => $f)
{
if (!$fname_html =& $forum_name_html[$fid])
{
continue;
}
$is_sf = $f['forum_parent'];
foreach ($c['f'] as $fid => $f) {
if (!$fname_html =& $forum_name_html[$fid]) {
continue;
}
$is_sf = $f['forum_parent'];
$forums_count++;
$new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : '';
$folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
$forums_count++;
$new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : '';
$folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
if ($f['forum_status'] == FORUM_LOCKED)
{
$folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked'];
}
if ($f['forum_status'] == FORUM_LOCKED) {
$folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked'];
}
if ($is_sf)
{
$template->assign_block_vars('c.f.sf', array(
'SF_ID' => $fid,
'SF_NAME' => $fname_html,
'SF_NEW' => $new ? ' new' : '',
));
continue;
}
if ($is_sf) {
$template->assign_block_vars('c.f.sf', array(
'SF_ID' => $fid,
'SF_NAME' => $fname_html,
'SF_NEW' => $new ? ' new' : '',
));
continue;
}
$template->assign_block_vars('c.f', array(
'FORUM_FOLDER_IMG' => $folder_image,
'FORUM_ID' => $fid,
'FORUM_NAME' => $fname_html,
'FORUM_DESC' => $f['forum_desc'],
'POSTS' => commify($f['forum_posts']),
'TOPICS' => commify($f['forum_topics']),
'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null,
'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '',
'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'],
));
$template->assign_block_vars('c.f', array(
'FORUM_FOLDER_IMG' => $folder_image,
'FORUM_ID' => $fid,
'FORUM_NAME' => $fname_html,
'FORUM_DESC' => $f['forum_desc'],
'POSTS' => commify($f['forum_posts']),
'TOPICS' => commify($f['forum_topics']),
'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null,
'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '',
'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'],
));
if ($f['last_post_id'])
{
$template->assign_block_vars('c.f.last', array(
'LAST_TOPIC_ID' => $f['last_topic_id'],
'LAST_TOPIC_TIP' => $f['last_topic_title'],
'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)),
'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']),
'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])),
));
}
}
if ($f['last_post_id']) {
$template->assign_block_vars('c.f.last', array(
'LAST_TOPIC_ID' => $f['last_topic_id'],
'LAST_TOPIC_TIP' => $f['last_topic_title'],
'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)),
'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']),
'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])),
));
}
}
}
$template->assign_vars(array(
'SHOW_FORUMS' => $forums_count,
'SHOW_MAP' => (isset($_GET['map']) && !IS_GUEST),
'PAGE_TITLE' => ($viewcat) ? $cat_title_html[$viewcat] : $lang['HOME'],
'NO_FORUMS_MSG' => ($only_new) ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'],
'SHOW_FORUMS' => $forums_count,
'SHOW_MAP' => (isset($_GET['map']) && !IS_GUEST),
'PAGE_TITLE' => ($viewcat) ? $cat_title_html[$viewcat] : $lang['HOME'],
'NO_FORUMS_MSG' => ($only_new) ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'],
'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']),
'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']),
'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']),
'TOTAL_GENDER' => ($bb_cfg['gender']) ? sprintf($lang['USERS_TOTAL_GENDER'], $stats['male'], $stats['female'], $stats['unselect']) : '',
'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])),
'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']),
'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']),
'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']),
'TOTAL_GENDER' => ($bb_cfg['gender']) ? sprintf($lang['USERS_TOTAL_GENDER'], $stats['male'], $stats['female'], $stats['unselect']) : '',
'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])),
// Tracker stats
'TORRENTS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['TORRENTS_STAT'], $stats['torrentcount'], humn_size($stats['size'])) : '',
'PEERS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['PEERS_STAT'], $stats['peers'], $stats['seeders'], $stats['leechers']) : '',
'SPEED_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['SPEED_STAT'], humn_size($stats['speed']) .'/s') : '',
'SHOW_MOD_INDEX' => $bb_cfg['show_mod_index'],
'FORUM_IMG' => $images['forum'],
'FORUM_NEW_IMG' => $images['forum_new'],
'FORUM_LOCKED_IMG' => $images['forum_locked'],
// Tracker stats
'TORRENTS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['TORRENTS_STAT'], $stats['torrentcount'], humn_size($stats['size'])) : '',
'PEERS_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['PEERS_STAT'], $stats['peers'], $stats['seeders'], $stats['leechers']) : '',
'SPEED_STAT' => ($bb_cfg['tor_stats']) ? sprintf($lang['SPEED_STAT'], humn_size($stats['speed']) . '/s') : '',
'SHOW_MOD_INDEX' => $bb_cfg['show_mod_index'],
'FORUM_IMG' => $images['forum'],
'FORUM_NEW_IMG' => $images['forum_new'],
'FORUM_LOCKED_IMG' => $images['forum_locked'],
'SHOW_ONLY_NEW_MENU' => true,
'ONLY_NEW_POSTS_ON' => ($only_new == ONLY_NEW_POSTS),
'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS),
'SHOW_ONLY_NEW_MENU' => true,
'ONLY_NEW_POSTS_ON' => ($only_new == ONLY_NEW_POSTS),
'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS),
'U_SEARCH_NEW' => "search.php?new=1",
'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&amp;o=1",
'U_SEARCH_LATEST' => "search.php?search_id=latest",
'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered",
'U_SEARCH_NEW' => "search.php?new=1",
'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&amp;o=1",
'U_SEARCH_LATEST' => "search.php?search_id=latest",
'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered",
'SHOW_LAST_TOPIC' => $show_last_topic,
'SHOW_LAST_TOPIC' => $show_last_topic,
));
// Set tpl vars for bt_userdata
if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST)
{
show_bt_userdata($userdata['user_id']);
if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) {
show_bt_userdata($userdata['user_id']);
}
// Latest news
if ($bb_cfg['show_latest_news'])
{
if (!$latest_news = $datastore->get('latest_news'))
{
$datastore->update('latest_news');
$latest_news = $datastore->get('latest_news');
}
if ($bb_cfg['show_latest_news']) {
if (!$latest_news = $datastore->get('latest_news')) {
$datastore->update('latest_news');
$latest_news = $datastore->get('latest_news');
}
$template->assign_vars(array(
'SHOW_LATEST_NEWS' => true,
));
$template->assign_vars(array(
'SHOW_LATEST_NEWS' => true,
));
foreach ($latest_news as $news)
{
$template->assign_block_vars('news', array(
'NEWS_TOPIC_ID' => $news['topic_id'],
'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']),
'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']),
));
}
foreach ($latest_news as $news) {
$template->assign_block_vars('news', array(
'NEWS_TOPIC_ID' => $news['topic_id'],
'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']),
'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']),
));
}
}
// Network news
if ($bb_cfg['show_network_news'])
{
if (!$network_news = $datastore->get('network_news'))
{
$datastore->update('network_news');
$network_news = $datastore->get('network_news');
}
if ($bb_cfg['show_network_news']) {
if (!$network_news = $datastore->get('network_news')) {
$datastore->update('network_news');
$network_news = $datastore->get('network_news');
}
$template->assign_vars(array(
'SHOW_NETWORK_NEWS' => true,
));
$template->assign_vars(array(
'SHOW_NETWORK_NEWS' => true,
));
foreach ($network_news as $net)
{
$template->assign_block_vars('net', array(
'NEWS_TOPIC_ID' => $net['topic_id'],
'NEWS_TITLE' => str_short($net['topic_title'], $bb_cfg['max_net_title']),
'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']),
));
}
foreach ($network_news as $net) {
$template->assign_block_vars('net', array(
'NEWS_TOPIC_ID' => $net['topic_id'],
'NEWS_TITLE' => str_short($net['topic_title'], $bb_cfg['max_net_title']),
'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']),
));
}
}
if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
{
$week_list = $today_list = array();
$week_all = $today_all = false;
if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
$week_list = $today_list = array();
$week_all = $today_all = false;
if ($stats['birthday_week_list'])
{
shuffle($stats['birthday_week_list']);
foreach ($stats['birthday_week_list'] as $i => $week)
{
if ($i >= 5)
{
$week_all = true;
continue;
}
$week_list[] = profile_url($week) .' <span class="small">('. birthday_age($week['user_birthday']-1) .')</span>';
}
$week_all = ($week_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="'. $lang['ALL'] .'">...</a>' : '';
$week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all;
}
else $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
if ($stats['birthday_week_list']) {
shuffle($stats['birthday_week_list']);
foreach ($stats['birthday_week_list'] as $i => $week) {
if ($i >= 5) {
$week_all = true;
continue;
}
$week_list[] = profile_url($week) . ' <span class="small">(' . birthday_age($week['user_birthday'] - 1) . ')</span>';
}
$week_all = ($week_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : '';
$week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all;
} else {
$week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
}
if ($stats['birthday_today_list'])
{
shuffle($stats['birthday_today_list']);
foreach ($stats['birthday_today_list'] as $i => $today)
{
if ($i >= 5)
{
$today_all = true;
continue;
}
$today_list[] = profile_url($today) .' <span class="small">('. birthday_age($today['user_birthday']) .')</span>';
}
$today_all = ($today_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_today\'}); return false;" title="'. $lang['ALL'] .'">...</a>' : '';
$today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all;
}
else $today_list = $lang['NOBIRTHDAY_TODAY'];
if ($stats['birthday_today_list']) {
shuffle($stats['birthday_today_list']);
foreach ($stats['birthday_today_list'] as $i => $today) {
if ($i >= 5) {
$today_all = true;
continue;
}
$today_list[] = profile_url($today) . ' <span class="small">(' . birthday_age($today['user_birthday']) . ')</span>';
}
$today_all = ($today_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_today\'}); return false;" title="' . $lang['ALL'] . '">...</a>' : '';
$today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all;
} else {
$today_list = $lang['NOBIRTHDAY_TODAY'];
}
$template->assign_vars(array(
'WHOSBIRTHDAY_WEEK' => $week_list,
'WHOSBIRTHDAY_TODAY' => $today_list,
));
$template->assign_vars(array(
'WHOSBIRTHDAY_WEEK' => $week_list,
'WHOSBIRTHDAY_TODAY' => $today_list,
));
}
// Allow cron
if (IS_AM)
{
if (file_exists(CRON_RUNNING))
{
if (file_exists(CRON_ALLOWED))
{
unlink (CRON_ALLOWED);
}
rename(CRON_RUNNING, CRON_ALLOWED);
}
if (IS_AM) {
if (file_exists(CRON_RUNNING)) {
if (file_exists(CRON_ALLOWED)) {
unlink(CRON_ALLOWED);
}
rename(CRON_RUNNING, CRON_ALLOWED);
}
}
// Display page
define('SHOW_ONLINE', $show_online_users);
if (isset($_GET['map'])) $template->assign_vars(array('PAGE_TITLE' => $lang['FORUM_MAP']));
if (isset($_GET['map'])) {
$template->assign_vars(array('PAGE_TITLE' => $lang['FORUM_MAP']));
}
print_page('index.tpl');
print_page('index.tpl');

112
info.php
View file

@ -1,8 +1,31 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('BB_SCRIPT', 'info');
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
// Start session management
$user->session_start();
@ -11,32 +34,31 @@ global $lang;
$info = array();
$html_dir = LANG_DIR . 'html/';
$req_mode = !empty($_REQUEST['show']) ? (string) $_REQUEST['show'] : 'not_found';
$req_mode = !empty($_REQUEST['show']) ? (string)$_REQUEST['show'] : 'not_found';
switch ($req_mode)
{
case 'advert':
$info['title'] = $lang['ADVERT'];
$info['src'] = 'advert.html';
break;
switch ($req_mode) {
case 'advert':
$info['title'] = $lang['ADVERT'];
$info['src'] = 'advert.html';
break;
case 'copyright_holders':
$info['title'] = $lang['COPYRIGHT_HOLDERS'];
$info['src'] = 'copyright_holders.html';
break;
case 'copyright_holders':
$info['title'] = $lang['COPYRIGHT_HOLDERS'];
$info['src'] = 'copyright_holders.html';
break;
case 'not_found':
$info['title'] = $lang['NOT_FOUND'];
$info['src'] = 'not_found.html';
break;
case 'not_found':
$info['title'] = $lang['NOT_FOUND'];
$info['src'] = 'not_found.html';
break;
case 'user_agreement':
$info['title'] = $lang['USER_AGREEMENT'];
$info['src'] = 'user_agreement.html';
break;
case 'user_agreement':
$info['title'] = $lang['USER_AGREEMENT'];
$info['src'] = 'user_agreement.html';
break;
default:
bb_simple_die('Invalid request');
default:
bb_simple_die('Invalid request');
}
$require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $html_dir . 'not_found.html';
@ -44,28 +66,40 @@ $require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $h
?><!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" href="styles/templates/default/css/main.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<link rel="stylesheet" href="styles/templates/default/css/main.css" type="text/css">
</head>
<body>
<style type="text/css">
#infobox-wrap { width: 760px; }
#infobox-body {
background: #FFFFFF; color: #000000; padding: 1em;
height: 400px; overflow: auto; border: 1px inset #000000;
}
#infobox-body p { margin-top: 1em; margin-bottom: 1em; }
#infobox-wrap {
width: 760px;
}
#infobox-body {
background: #FFFFFF;
color: #000000;
padding: 1em;
height: 400px;
overflow: auto;
border: 1px inset #000000;
}
#infobox-body p {
margin-top: 1em;
margin-bottom: 1em;
}
</style>
<br />
<br/>
<div id="infobox-wrap" class="bCenter row1">
<fieldset class="pad_6">
<legend class="med bold mrg_2 warnColor1"><?php echo mb_strtoupper($info['title'], 'UTF-8'); ?></legend>
<div class="bCenter">
<?php require($require); ?>
</div>
</fieldset>
<p class="gen tRight pad_6"><a href="javascript:window.close();" class="gen">[ <?php echo $lang['LOCK']; ?> ]</a></p>
<fieldset class="pad_6">
<legend class="med bold mrg_2 warnColor1"><?php echo mb_strtoupper($info['title'], 'UTF-8'); ?></legend>
<div class="bCenter">
<?php require($require); ?>
</div>
</fieldset>
<p class="gen tRight pad_6"><a href="javascript:window.close();" class="gen">[ <?php echo $lang['LOCK']; ?> ]</a>
</p>
</div><!--/infobox-wrap-->
</body>
</html>

View file

@ -1,34 +1,55 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// TorrentPier bridge
define ('TP_ROOT', './../ptv/'); // Absolete or related local path to your TorrentPier installation
define ('USER_ID_DIFF', 1); // User_id difference between TP and TBDev (tp_user_id - tb_user_id)
define('TP_ROOT', './../ptv/'); // Absolete or related local path to your TorrentPier installation
define('USER_ID_DIFF', 1); // User_id difference between TP and TBDev (tp_user_id - tb_user_id)
// TorrentPier Database
$dbhost = 'localhost';
$dbname = 'dbase';
$dbuser = 'user';
$dbpasswd = 'pass';
$dbpasswd = 'pass';
$dbcharset = 'utf8';
// Start announce
define ('IN_ANNOUNCE', true);
define('IN_ANNOUNCE', true);
require_once('./include/core_announce.php');
$passkey = @$_GET['passkey'];
if (!$passkey)
{
err('Passkey required');
if (!$passkey) {
err('Passkey required');
}
dbconn();
$res = mysql_query("SELECT id FROM users WHERE passkey = " . sqlesc($passkey)) or err(mysql_error());
if (mysql_affected_rows() == 0)
{
err('Invalid passkey! Re-download the .torrent from '.$DEFAULTBASEURL);
if (mysql_affected_rows() == 0) {
err('Invalid passkey! Re-download the .torrent from ' . $DEFAULTBASEURL);
}
$user = mysql_fetch_array($res);
@ -45,9 +66,8 @@ mysql_query("SET NAMES $dbcharset");
$user_id += USER_ID_DIFF;
$res = mysql_query("SELECT auth_key FROM bb_bt_users WHERE user_id = $user_id") or err(mysql_error());
if (mysql_affected_rows() == 0)
{
err('Passkey doesn\'t created on new tracker or user doesn\'t exist');
if (mysql_affected_rows() == 0) {
err('Passkey doesn\'t created on new tracker or user doesn\'t exist');
}
$user = mysql_fetch_array($res);
@ -58,5 +78,5 @@ $_GET['uk'] = $user['auth_key'];
unset($res, $user, $dbpasswd, $passkey, $user_id);
// Execute TP's announce
chdir(TP_ROOT .'bt/');
chdir(TP_ROOT . 'bt/');
require('announce.php');

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
require_once("include/bittorrent.php");
@ -8,37 +31,35 @@ loggedinorreturn();
$new_tr_url = "http://torrentpier.me/"; // with ending slash
$subject = "Переезд на новый движок";
$msg = '[b]Внимание![/b] Наш трекер переехал на новый движок! Адрес трекера - [url='.$new_tr_url.']'.$new_tr_url.'[/url]
$msg = '[b]Внимание![/b] Наш трекер переехал на новый движок! Адрес трекера - [url=' . $new_tr_url . ']' . $new_tr_url . '[/url]
Вся база перенесена на новый движок, регистрироваться заново не надо.
Войти на трекер можно [url='.$new_tr_url.'login.php]здесь[/url]. Ваши данные на новом трекере:
Войти на трекер можно [url=' . $new_tr_url . 'login.php]здесь[/url]. Ваши данные на новом трекере:
[b]Логин:[/b] %s
[b]Пароль:[/b] %s
Сменить пароль можно после входа на трекер в [url='.$new_tr_url.'profile.php?mode=editprofile]настройках[/url].';
Сменить пароль можно после входа на трекер в [url=' . $new_tr_url . 'profile.php?mode=editprofile]настройках[/url].';
if (empty($_POST['confirm']))
{
stdhead();
echo '
if (empty($_POST['confirm'])) {
stdhead();
echo '
<br />
<center>
<form action="'. $_SERVER['PHP_SELF'] .'" method="post">
<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
<input type="submit" name="confirm" value="Start mass PM" />
</form>
</center>
';
}
else
{
if (!file_exists('passwords.php')) stderr($tracker_lang['error'], 'passwords.php not exists');
} else {
if (!file_exists('passwords.php')) {
stderr($tracker_lang['error'], 'passwords.php not exists');
}
include('passwords.php');
stdhead();
foreach ($passwords as $user)
{
$msg_sql = sprintf($msg, $user['username'], $user['new_passwd']);
sql_query("INSERT INTO messages (receiver, added, subject, msg) VALUES({$user['tb_user_id']}, NOW(), ".sqlesc($subject).", ".sqlesc($msg_sql).")");
}
stdmsg('OK', 'Mass PM succesful');
include('passwords.php');
stdhead();
foreach ($passwords as $user) {
$msg_sql = sprintf($msg, $user['username'], $user['new_passwd']);
sql_query("INSERT INTO messages (receiver, added, subject, msg) VALUES({$user['tb_user_id']}, NOW(), " . sqlesc($subject) . ", " . sqlesc($msg_sql) . ")");
}
stdmsg('OK', 'Mass PM succesful');
}
stdfoot();
stdfoot();

View file

@ -1,8 +1,31 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define ('IN_FORUM', true);
define ('BB_ROOT', './');
require (BB_ROOT .'common.php');
define('IN_FORUM', true);
define('BB_ROOT', './');
require(BB_ROOT . 'common.php');
require(BB_ROOT . 'converter/constants.php');
require(BB_ROOT . 'converter/settings.php');
require(BB_ROOT . 'converter/functions.php');
@ -10,252 +33,237 @@ require(BB_ROOT . 'converter/functions.php');
// Start session management
$user->session_start();
if (!IS_ADMIN) die("Restricted access");
while (@ob_end_flush());
if (!IS_ADMIN) {
die("Restricted access");
}
while (@ob_end_flush()) ;
ob_implicit_flush();
error_reporting(E_ALL);
@ini_set('display_errors', 1);
?>
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
</head>
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
</head>
<body style="font: 12px Courier, monospace; white-space: nowrap;">
<?php
if (empty($_POST['confirm']))
{
echo '
if (empty($_POST['confirm'])) {
echo '
<br />
<center>
<form action="'. $_SERVER['PHP_SELF'] .'" method="post">
<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
<input type="submit" name="confirm" value="Start convert" />
</form>
</center>
</body>
';
exit;
}
else
{
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
exit;
} else {
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
// Step 1: Converting Users
if (CONVERT_USERS)
{
if (CLEAN)
{
tp_users_cleanup();
print_ok ("Users cleared");
}
if (CONVERT_USERS) {
if (CLEAN) {
tp_users_cleanup();
print_ok("Users cleared");
}
$max_uid = (int) get_max_val(BB_USERS, 'user_id');
$max_uid = ($max_uid > 1) ? $max_uid : 1;
$max_uid = (int)get_max_val(BB_USERS, 'user_id');
$max_uid = ($max_uid > 1) ? $max_uid : 1;
$users_count = (int) get_count(TB_USERS_TABLE, 'id');
$loops = (int) ceil($users_count / C_USERS_PER_ONCE);
$pass = array();
$users_count = (int)get_count(TB_USERS_TABLE, 'id');
$loops = (int)ceil($users_count / C_USERS_PER_ONCE);
$pass = array();
switch(TR_TYPE)
{
case 'yse':
$_sql = 'avatar, ';
break;
switch (TR_TYPE) {
case 'yse':
$_sql = 'avatar, ';
break;
default:
$_sql = '';
break;
}
default:
$_sql = '';
break;
}
for ($i = 0; $i < $loops; $i++)
{
$start = $i * C_USERS_PER_ONCE;
$offset = C_USERS_PER_ONCE;
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_USERS_PER_ONCE;
$offset = C_USERS_PER_ONCE;
$sql = "
$sql = "
SELECT
id, username, email, status, UNIX_TIMESTAMP(added) AS added, UNIX_TIMESTAMP(last_access) AS last_access,
class, icq, msn, aim, yahoo, website, $_sql
uploaded, downloaded, enabled, language
FROM ". TB_USERS_TABLE ."
FROM " . TB_USERS_TABLE . "
ORDER BY id
LIMIT $start, $offset";
$users = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
$users = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($users as $user)
{
$user['id'] += $max_uid;
$user['password'] = make_rand_str(15);
convert_user($user);
$pass[] = array(
'tb_user_id' => $user['id'] - $max_uid,
'username' => $user['username'],
'new_passwd' => $user['password'],
);
}
}
$passf = fopen('./converter/passwords.php', 'w');
$to_write = "<?php \n";
$to_write .= '$passwords = '. var_export($pass, true) .';';
fwrite($passf, $to_write);
fclose($passf);
set_auto_increment(BB_USERS, 'user_id');
foreach ($users as $user) {
$user['id'] += $max_uid;
$user['password'] = make_rand_str(15);
convert_user($user);
$pass[] = array(
'tb_user_id' => $user['id'] - $max_uid,
'username' => $user['username'],
'new_passwd' => $user['password'],
);
}
}
$passf = fopen('./converter/passwords.php', 'w');
$to_write = "<?php \n";
$to_write .= '$passwords = ' . var_export($pass, true) . ';';
fwrite($passf, $to_write);
fclose($passf);
set_auto_increment(BB_USERS, 'user_id');
print_ok ("Total $users_count users from TBDev converted");
unset($users, $pass, $to_write);
}
print_ok("Total $users_count users from TBDev converted");
unset($users, $pass, $to_write);
}
if (CONVERT_TORRENTS)
{
require_once(INC_DIR .'functions_post.php');
require_once(INC_DIR .'bbcode.php');
if (CONVERT_TORRENTS) {
require_once(INC_DIR . 'functions_post.php');
require_once(INC_DIR . 'bbcode.php');
if (CLEAN)
{
tp_categories_cleanup();
tp_forums_cleanup();
tp_topics_cleanup();
print_ok ("Categories, forums and topics cleared");
}
if (CLEAN) {
tp_categories_cleanup();
tp_forums_cleanup();
tp_topics_cleanup();
print_ok("Categories, forums and topics cleared");
}
$max_uid = !empty($max_uid) ? $max_uid : 1;
$max_uid = !empty($max_uid) ? $max_uid : 1;
//Create a category for torrents
$max_cat_id = (int) get_max_val(BB_CATEGORIES, 'cat_id');
$tr_cat_id = $max_cat_id + 1;
//Create a category for torrents
$max_cat_id = (int)get_max_val(BB_CATEGORIES, 'cat_id');
$tr_cat_id = $max_cat_id + 1;
$tp_cat_data = array(
"cat_id" => $tr_cat_id,
"cat_title" => 'Tracker',
);
tp_add_category($tp_cat_data);
set_auto_increment(BB_CATEGORIES, 'cat_id');
unset($tp_cat_data);
$tp_cat_data = array(
"cat_id" => $tr_cat_id,
"cat_title" => 'Tracker',
);
tp_add_category($tp_cat_data);
set_auto_increment(BB_CATEGORIES, 'cat_id');
unset($tp_cat_data);
$cats = $db->fetch_rowset("SELECT id, sort, name FROM ". TB_CATEGORIES_TABLE);
DB()->sql_freeresult();
$cats = $db->fetch_rowset("SELECT id, sort, name FROM " . TB_CATEGORIES_TABLE);
DB()->sql_freeresult();
$max_forum_id = (int) get_max_val(BB_FORUMS, 'forum_id');
$max_forum_id = (int)get_max_val(BB_FORUMS, 'forum_id');
foreach ($cats as $cat)
{
$cat['id'] += $max_forum_id;
$cat['cat_id'] = $tr_cat_id;
convert_cat($cat);
}
set_auto_increment(BB_FORUMS, 'forum_id');
print_ok ("Categories from TBDev converted");
unset($cats);
foreach ($cats as $cat) {
$cat['id'] += $max_forum_id;
$cat['cat_id'] = $tr_cat_id;
convert_cat($cat);
}
set_auto_increment(BB_FORUMS, 'forum_id');
print_ok("Categories from TBDev converted");
unset($cats);
// Start of torrents converting
switch(TR_TYPE)
{
case 'yse':
$_sql = 'image1, image2, ';
break;
// Start of torrents converting
switch (TR_TYPE) {
case 'yse':
$_sql = 'image1, image2, ';
break;
case 'sky':
$_sql = 'poster, screenshot1, screenshot2, screenshot3, screenshot4, ';
break;
case 'sky':
$_sql = 'poster, screenshot1, screenshot2, screenshot3, screenshot4, ';
break;
default:
$_sql = '';
break;
}
default:
$_sql = '';
break;
}
$max_topic_id = (int) get_max_val(BB_TOPICS, 'topic_id');
$max_post_id = (int) get_max_val(BB_POSTS, 'post_id');
$max_attach_id = (int) get_max_val(BB_ATTACHMENTS, 'attach_id');
$max_topic_id = (int)get_max_val(BB_TOPICS, 'topic_id');
$max_post_id = (int)get_max_val(BB_POSTS, 'post_id');
$max_attach_id = (int)get_max_val(BB_ATTACHMENTS, 'attach_id');
$torrents_count = (int) get_count(TB_TORRENTS_TABLE, 'id');
$loops = (int) ceil($torrents_count / C_TORRENTS_PER_ONCE);
$torrents_count = (int)get_count(TB_TORRENTS_TABLE, 'id');
$loops = (int)ceil($torrents_count / C_TORRENTS_PER_ONCE);
for ($i = 0; $i < $loops; $i++)
{
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
$sql = "
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
$sql = "
SELECT
id, info_hash, name, filename, search_text, descr, $_sql
category, UNIX_TIMESTAMP(added) AS added, size, views,
UNIX_TIMESTAMP(last_action) AS lastseed, times_completed, owner, sticky
FROM ". TB_TORRENTS_TABLE ."
FROM " . TB_TORRENTS_TABLE . "
ORDER BY id
LIMIT $start, $offset";
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($torrents as $torrent)
{
$torrent['topic_id'] = $torrent['id'] + $max_topic_id;
$torrent['post_id'] = $torrent['id'] + $max_post_id;
$torrent['attach_id'] = $torrent['id'] + $max_attach_id;
$torrent['owner'] += $max_uid;
$torrent['descr'] = append_images($torrent);
convert_torrent($torrent);
//print_r($torrent);
}
}
set_auto_increment(BB_TOPICS, 'topic_id');
set_auto_increment(BB_POSTS, 'post_id');
print_ok ("Total $torrents_count torrents from TBDev converted");
unset($torrents);
foreach ($torrents as $torrent) {
$torrent['topic_id'] = $torrent['id'] + $max_topic_id;
$torrent['post_id'] = $torrent['id'] + $max_post_id;
$torrent['attach_id'] = $torrent['id'] + $max_attach_id;
$torrent['owner'] += $max_uid;
$torrent['descr'] = append_images($torrent);
convert_torrent($torrent);
//print_r($torrent);
}
}
set_auto_increment(BB_TOPICS, 'topic_id');
set_auto_increment(BB_POSTS, 'post_id');
print_ok("Total $torrents_count torrents from TBDev converted");
unset($torrents);
if (CONVERT_COMMENTS)
{
$max_post_id = (int) get_max_val(BB_POSTS, 'post_id');
$max_topic_id = (int) get_max_val(BB_TOPICS, 'topic_id');
$max_attach_id = (int) get_max_val(BB_ATTACHMENTS, 'attach_id');
if (CONVERT_COMMENTS) {
$max_post_id = (int)get_max_val(BB_POSTS, 'post_id');
$max_topic_id = (int)get_max_val(BB_TOPICS, 'topic_id');
$max_attach_id = (int)get_max_val(BB_ATTACHMENTS, 'attach_id');
$comments_count = (int) get_count(TB_COMMENTS_TABLE, 'id');
$loops = (int) ceil($comments_count / C_COMMENTS_PER_ONCE);
$comments_count = (int)get_count(TB_COMMENTS_TABLE, 'id');
$loops = (int)ceil($comments_count / C_COMMENTS_PER_ONCE);
for ($i = 0; $i < $loops; $i++)
{
$start = $i * C_COMMENTS_PER_ONCE;
$offset = C_COMMENTS_PER_ONCE;
$sql = "
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_COMMENTS_PER_ONCE;
$offset = C_COMMENTS_PER_ONCE;
$sql = "
SELECT
c.id, c.user, c.torrent, c.text, tor.category,
UNIX_TIMESTAMP(c.added) AS added, UNIX_TIMESTAMP(c.editedat) AS editedat, c.ip
FROM ". TB_COMMENTS_TABLE ." c
LEFT JOIN ". TB_TORRENTS_TABLE ." tor ON(tor.id = c.torrent)
FROM " . TB_COMMENTS_TABLE . " c
LEFT JOIN " . TB_TORRENTS_TABLE . " tor ON(tor.id = c.torrent)
WHERE c.torrent <> 0
ORDER BY c.id
LIMIT $start, $offset";
$comments = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
$comments = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($comments as $comment)
{
$comment['user'] += $max_uid;
$comment['id'] += $max_post_id;
convert_comment($comment);
}
}
unset($comments);
set_auto_increment(BB_POSTS, 'post_id');
print_ok ("Total $comments_count comments from TBDev converted");
}
}
foreach ($comments as $comment) {
$comment['user'] += $max_uid;
$comment['id'] += $max_post_id;
convert_comment($comment);
}
}
unset($comments);
set_auto_increment(BB_POSTS, 'post_id');
print_ok("Total $comments_count comments from TBDev converted");
}
}
?>
</div>
<br />
Converting completed.
</body>
</html>
<?php } ?>
?>
</div>
<br/>
Converting completed.
</body>
</html>
<?php
} ?>

View file

@ -1,8 +1,33 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('EXCLUDED_USERS_CSV')) { define('EXCLUDED_USERS_CSV', join(',', array(GUEST_UID, BOT_UID,))); }
define('TB_USERS_TABLE', 'users');
if (!defined('EXCLUDED_USERS_CSV')) {
define('EXCLUDED_USERS_CSV', join(',', array(GUEST_UID, BOT_UID,)));
}
define('TB_USERS_TABLE', 'users');
define('TB_CATEGORIES_TABLE', 'categories');
define('TB_TORRENTS_TABLE', 'torrents');
define('TB_COMMENTS_TABLE', 'comments');
define('MYBB_FORUMS_TABLE', 'mybb_forums');
define('TB_TORRENTS_TABLE', 'torrents');
define('TB_COMMENTS_TABLE', 'comments');
define('MYBB_FORUMS_TABLE', 'mybb_forums');

View file

@ -1,424 +1,426 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
function print_ok ($sql)
function print_ok($sql)
{
global $err;
global $err;
echo ($err) ? "\n<br />" : '';
$err = '';
echo ($err) ? "\n<br />" : '';
$err = '';
echo '<div>';
echo "<font color=darkgreen><b>OK</b> - $sql</font>". str_repeat(' ', 256) ."\n<br />";
echo '</div>';
echo '<div>';
echo "<font color=darkgreen><b>OK</b> - $sql</font>" . str_repeat(' ', 256) . "\n<br />";
echo '</div>';
}
function hex2bin($h)
{
if (!is_string($h)) return null;
$r='';
for ($a=0; $a<strlen($h); $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); }
return $r;
if (!is_string($h)) return null;
$r = '';
for ($a = 0; $a < strlen($h); $a += 2) {
$r .= chr(hexdec($h{$a} . $h{($a + 1)}));
}
return $r;
}
function get_max_val($table_name, $column)
{
$row = DB()->fetch_row("SELECT MAX($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
$row = DB()->fetch_row("SELECT MAX($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
}
function get_count($table_name, $column)
{
$row = DB()->fetch_row("SELECT COUNT($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
$row = DB()->fetch_row("SELECT COUNT($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
}
function set_auto_increment($table_name, $column, $val = null)
{
if (empty($val))
{
$row = DB()->fetch_row("SELECT MAX($column) AS val FROM $table_name LIMIT 1");
DB()->sql_freeresult();
$val = (int) $row['val'] + 1;
}
DB()->query("ALTER TABLE $table_name auto_increment = $val");
if (empty($val)) {
$row = DB()->fetch_row("SELECT MAX($column) AS val FROM $table_name LIMIT 1");
DB()->sql_freeresult();
$val = (int)$row['val'] + 1;
}
DB()->query("ALTER TABLE $table_name auto_increment = $val");
}
// Users functions
function tp_users_cleanup()
{
DB()->query('DELETE FROM '. BB_USERS .' WHERE user_id NOT IN('. EXCLUDED_USERS_CSV .')');
DB()->query('TRUNCATE '. BB_BT_USERS);
DB()->query('DELETE FROM ' . BB_USERS . ' WHERE user_id NOT IN(' . EXCLUDED_USERS_CSV . ')');
DB()->query('TRUNCATE ' . BB_BT_USERS);
}
function tp_user_level($tb_class)
{
switch($tb_class)
{
case 0:
case 1:
case 2:
case 3:
$level = 0;
break;
case 4:
$level = 2;
break;
case 5:
case 6:
case 7:
$level = 1;
break;
default:
$level = 0;
break;
}
return $level;
switch ($tb_class) {
case 0:
case 1:
case 2:
case 3:
$level = 0;
break;
case 4:
$level = 2;
break;
case 5:
case 6:
case 7:
$level = 1;
break;
default:
$level = 0;
break;
}
return $level;
}
function convert_user($user)
{
$user_data = array(
"user_id" => $user['id'],
"user_active" => ($user['enabled'] == 'yes') ? true : false,
"username" => $user['username'],
"user_password" => md5($user['password']),
"user_lastvisit" => $user['last_access'],
"user_regdate" => $user['added'],
"user_level" => tp_user_level($user['class']),
"user_lang" => $user['language'],
"user_dateformat" => "Y-m-d H:i",
"user_opt" => 0,
"user_avatar" => !empty($user['avatar']) ? $user['avatar'] : null,
"user_avatar_type" => !empty($user['avatar']) ? 2 : null,
"user_email" => $user['email'],
"user_website" => $user['website'],
);
$user_data = array(
"user_id" => $user['id'],
"user_active" => ($user['enabled'] == 'yes') ? true : false,
"username" => $user['username'],
"user_password" => md5($user['password']),
"user_lastvisit" => $user['last_access'],
"user_regdate" => $user['added'],
"user_level" => tp_user_level($user['class']),
"user_lang" => $user['language'],
"user_dateformat" => "Y-m-d H:i",
"user_opt" => 0,
"user_avatar" => !empty($user['avatar']) ? $user['avatar'] : null,
"user_avatar_type" => !empty($user['avatar']) ? 2 : null,
"user_email" => $user['email'],
"user_website" => $user['website'],
);
$columns = $values = array();
$columns = $values = array();
foreach ($user_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_USERS . " ($sql_columns) VALUES($sql_values);");
DB()->query("INSERT IGNORE INTO " . BB_USERS . " ($sql_columns) VALUES($sql_values);");
$bt_user_data = array(
"user_id" => $user['id'],
"auth_key" => make_rand_str(BT_AUTH_KEY_LENGTH),
"u_up_total" => $user['uploaded'],
"u_down_total" => $user['downloaded'],
);
$columns = $values = array();
$bt_user_data = array(
"user_id" => $user['id'],
"auth_key" => make_rand_str(BT_AUTH_KEY_LENGTH),
"u_up_total" => $user['uploaded'],
"u_down_total" => $user['downloaded'],
);
$columns = $values = array();
foreach ($bt_user_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
foreach ($bt_user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_BT_USERS . " ($sql_bt_columns) VALUES($sql_bt_values);");
DB()->query("INSERT IGNORE INTO " . BB_BT_USERS . " ($sql_bt_columns) VALUES($sql_bt_values);");
}
//Torrents and categories functions
function tp_categories_cleanup()
{
DB()->query('DELETE FROM '. BB_CATEGORIES);
DB()->query('DELETE FROM ' . BB_CATEGORIES);
}
function tp_add_category_old($id, $cat_title)
{
DB()->query("INSERT IGNORE INTO ". BB_CATEGORIES ." (cat_id, cat_title)
VALUES ($id, '". DB()->escape($cat_title) ."')");
return;
DB()->query("INSERT IGNORE INTO " . BB_CATEGORIES . " (cat_id, cat_title)
VALUES ($id, '" . DB()->escape($cat_title) . "')");
return;
}
function tp_add_category($cat_data)
{
$columns = $values = array();
$columns = $values = array();
foreach ($cat_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
foreach ($cat_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_CATEGORIES . " ($sql_bt_columns) VALUES($sql_bt_values);");
DB()->query("INSERT IGNORE INTO " . BB_CATEGORIES . " ($sql_bt_columns) VALUES($sql_bt_values);");
}
function tp_topics_cleanup()
{
DB()->query("TRUNCATE ". BB_ATTACHMENTS);
DB()->query("TRUNCATE ". BB_ATTACHMENTS_DESC);
DB()->query("TRUNCATE ". BB_BT_TORRENTS);
DB()->query("TRUNCATE ". BB_POSTS);
DB()->query("TRUNCATE ". BB_POSTS_HTML);
DB()->query("TRUNCATE ". BB_POSTS_SEARCH);
DB()->query("TRUNCATE ". BB_POSTS_TEXT);
DB()->query("TRUNCATE ". BB_TOPICS);
DB()->query("TRUNCATE " . BB_ATTACHMENTS);
DB()->query("TRUNCATE " . BB_ATTACHMENTS_DESC);
DB()->query("TRUNCATE " . BB_BT_TORRENTS);
DB()->query("TRUNCATE " . BB_POSTS);
DB()->query("TRUNCATE " . BB_POSTS_HTML);
DB()->query("TRUNCATE " . BB_POSTS_SEARCH);
DB()->query("TRUNCATE " . BB_POSTS_TEXT);
DB()->query("TRUNCATE " . BB_TOPICS);
return;
return;
}
function tp_add_topic($topic_data)
{
$columns = $values = array();
foreach ($topic_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
$columns = $values = array();
foreach ($topic_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_TOPICS . " ($sql_columns) VALUES($sql_values);");
return;
DB()->query("INSERT IGNORE INTO " . BB_TOPICS . " ($sql_columns) VALUES($sql_values);");
return;
}
function tp_add_post($post_data)
{
foreach ($post_data as $key => $data)
{
$columns = $values = array();
foreach ($data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($post_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES($sql_values);");
}
return;
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES($sql_values);");
}
return;
}
function tp_add_attach($attach_data)
{
foreach ($attach_data as $key => $data)
{
$columns = $values = array();
foreach ($data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($attach_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES($sql_values);");
}
return;
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES($sql_values);");
}
return;
}
function make_img_path ($name)
function make_img_path($name)
{
global $bb_cfg;
global $bb_cfg;
return make_url("files/images/" . $name);
return make_url("files/images/" . $name);
}
function append_images($tor)
{
$poster = $screens = '';
switch(TR_TYPE)
{
case 'yse':
if (!empty($tor['image1']))
{
$poster = "[img=right]".make_img_path($tor['image1'])."[/img]";
}
if (!empty($tor['image2']))
{
$screens = '[spoiler="Скриншоты"][img]'.make_img_path($tor['image2'])."[/img][/spoiler]";
}
break;
case 'sky':
if (!empty($tor['poster']))
{
$poster = "[img=right]".make_img_path($tor['poster'])."[/img]";
}
$has_screens = !empty($tor['screenshot1']) || !empty($tor['screenshot2']) || !empty($tor['screenshot3']) || !empty($tor['screenshot4']);
if ($has_screens)
{
$screens .= '[spoiler="Скриншоты"]';
for ($i = 1; $i <= 4; $i++)
{
if (!empty($tor['screenshot'.$i]))
{
$screens .= "[img]".make_img_path($tor['screenshot'.$i])."[/img] \n";
}
}
$screens .= "[/spoiler]";
}
break;
}
return ($poster . $tor['descr'] . $screens);
$poster = $screens = '';
switch (TR_TYPE) {
case 'yse':
if (!empty($tor['image1'])) {
$poster = "[img=right]" . make_img_path($tor['image1']) . "[/img]";
}
if (!empty($tor['image2'])) {
$screens = '[spoiler="Скриншоты"][img]' . make_img_path($tor['image2']) . "[/img][/spoiler]";
}
break;
case 'sky':
if (!empty($tor['poster'])) {
$poster = "[img=right]" . make_img_path($tor['poster']) . "[/img]";
}
$has_screens = !empty($tor['screenshot1']) || !empty($tor['screenshot2']) || !empty($tor['screenshot3']) || !empty($tor['screenshot4']);
if ($has_screens) {
$screens .= '[spoiler="Скриншоты"]';
for ($i = 1; $i <= 4; $i++) {
if (!empty($tor['screenshot' . $i])) {
$screens .= "[img]" . make_img_path($tor['screenshot' . $i]) . "[/img] \n";
}
}
$screens .= "[/spoiler]";
}
break;
}
return ($poster . $tor['descr'] . $screens);
}
function convert_torrent($torrent)
{
$topic_data = array(
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"topic_title" => $torrent['name'],
"topic_poster" => $torrent['owner'],
"topic_time" => $torrent['added'],
"topic_views" => $torrent['views'],
"topic_type" => ($torrent['sticky'] == 'yes') ? 1 : 0,
"topic_first_post_id" => $torrent['id'],
"topic_last_post_id" => $torrent['id'],
"topic_attachment" => 1,
"topic_dl_type" => 1,
"topic_last_post_time" => $torrent['added'],
);
tp_add_topic($topic_data);
$post_text = stripslashes(prepare_message(addslashes(unprepare_message($torrent['descr'])), true, true));
$topic_data = array(
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"topic_title" => $torrent['name'],
"topic_poster" => $torrent['owner'],
"topic_time" => $torrent['added'],
"topic_views" => $torrent['views'],
"topic_type" => ($torrent['sticky'] == 'yes') ? 1 : 0,
"topic_first_post_id" => $torrent['id'],
"topic_last_post_id" => $torrent['id'],
"topic_attachment" => 1,
"topic_dl_type" => 1,
"topic_last_post_time" => $torrent['added'],
);
tp_add_topic($topic_data);
$post_text = stripslashes(prepare_message(addslashes(unprepare_message($torrent['descr'])), true, true));
$post_data = array(
"posts" => array(
"post_id" => $torrent['post_id'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"poster_id" => $torrent['owner'],
"post_time" => $torrent['added'],
"post_attachment" => 1,
),
"posts_text" => array(
"post_id" => $torrent['post_id'],
"post_text" => $post_text,
),
"posts_search" => array(
"post_id" => $torrent['post_id'],
"search_words" => $torrent['search_text'],
),
);
tp_add_post($post_data);
$post_data = array(
"posts" => array(
"post_id" => $torrent['post_id'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"poster_id" => $torrent['owner'],
"post_time" => $torrent['added'],
"post_attachment" => 1,
),
"posts_text" => array(
"post_id" => $torrent['post_id'],
"post_text" => $post_text,
),
"posts_search" => array(
"post_id" => $torrent['post_id'],
"search_words" => $torrent['search_text'],
),
);
tp_add_post($post_data);
$attach_data = array(
"attachments" => array(
"attach_id" => $torrent['attach_id'],
"post_id" => $torrent['post_id'],
"user_id_1" => $torrent['owner'],
),
"attachments_desc" => array(
"attach_id" => $torrent['attach_id'],
"physical_filename" => $torrent['id'] . ".torrent",
"real_filename" => $torrent['filename'],
"extension" => "torrent",
"mimetype" => "application/x-bittorrent",
"filesize" => @filesize(get_attachments_dir() .'/'. $torrent['id'] .".torrent"),
"filetime" => $torrent['added'],
"tracker_status" => 1,
),
);
tp_add_attach($attach_data);
$attach_data = array(
"attachments" => array(
"attach_id" => $torrent['attach_id'],
"post_id" => $torrent['post_id'],
"user_id_1" => $torrent['owner'],
),
"attachments_desc" => array(
"attach_id" => $torrent['attach_id'],
"physical_filename" => $torrent['id'] . ".torrent",
"real_filename" => $torrent['filename'],
"extension" => "torrent",
"mimetype" => "application/x-bittorrent",
"filesize" => @filesize(get_attachments_dir() . '/' . $torrent['id'] . ".torrent"),
"filetime" => $torrent['added'],
"tracker_status" => 1,
),
);
tp_add_attach($attach_data);
//Torrents
if (BDECODE)
{
$filename = get_attachments_dir() .'/'. $torrent['id'] .".torrent";
if (!file_exists($filename))
{
return;
}
if (!function_exists('bdecode_file')) include_once(INC_DIR .'functions_torrent.php');
$tor = bdecode_file($filename);
$info = ($tor['info']) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
}
else
{
$info_hash_sql = hex2bin($torrent['info_hash']);
}
//Torrents
if (BDECODE) {
$filename = get_attachments_dir() . '/' . $torrent['id'] . ".torrent";
if (!file_exists($filename)) {
return;
}
if (!function_exists('bdecode_file')) include_once(INC_DIR . 'functions_torrent.php');
$tor = bdecode_file($filename);
$info = ($tor['info']) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
} else {
$info_hash_sql = hex2bin($torrent['info_hash']);
}
$torrent_data = array(
"info_hash" => $info_hash_sql,
"post_id" => $torrent['post_id'],
"poster_id" => $torrent['owner'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"attach_id" => $torrent['attach_id'],
"size" => $torrent['size'],
"reg_time" => $torrent['added'],
"complete_count" => $torrent['times_completed'],
"seeder_last_seen" => $torrent['lastseed'],
);
$torrent_data = array(
"info_hash" => $info_hash_sql,
"post_id" => $torrent['post_id'],
"poster_id" => $torrent['owner'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"attach_id" => $torrent['attach_id'],
"size" => $torrent['size'],
"reg_time" => $torrent['added'],
"complete_count" => $torrent['times_completed'],
"seeder_last_seen" => $torrent['lastseed'],
);
$columns = $values = array();
$columns = $values = array();
foreach ($torrent_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". $db->escape($value) ."'";
}
$sql_columns = implode(', ', $columns);
$sql_values = implode(', ', $values);
foreach ($torrent_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . $db->escape($value) . "'";
}
$sql_columns = implode(', ', $columns);
$sql_values = implode(', ', $values);
DB()->query("INSERT IGNORE INTO ". BB_BT_TORRENTS . " ($sql_columns) VALUES($sql_values);");
return;
DB()->query("INSERT IGNORE INTO " . BB_BT_TORRENTS . " ($sql_columns) VALUES($sql_values);");
return;
}
// Comments functions
function convert_comment($comment)
{
$post_text = prepare_message($comment['text'], true, true);
$post_text = prepare_message($comment['text'], true, true);
$post_data = array(
"posts" => array(
"post_id" => $comment['id'],
"topic_id" => $comment['torrent'],
"forum_id" => $comment['category'],
"poster_id" => $comment['user'],
"post_time" => $comment['added'],
"poster_ip" => encode_ip($comment['ip']),
"post_edit_time" => $comment['editedat'],
"post_edit_count" => $comment['editedat'] ? 1 : 0,
),
"posts_text" => array(
"post_id" => $comment['id'],
"post_text" => $post_text,
),
);
tp_add_post($post_data);
return;
$post_data = array(
"posts" => array(
"post_id" => $comment['id'],
"topic_id" => $comment['torrent'],
"forum_id" => $comment['category'],
"poster_id" => $comment['user'],
"post_time" => $comment['added'],
"poster_ip" => encode_ip($comment['ip']),
"post_edit_time" => $comment['editedat'],
"post_edit_count" => $comment['editedat'] ? 1 : 0,
),
"posts_text" => array(
"post_id" => $comment['id'],
"post_text" => $post_text,
),
);
tp_add_post($post_data);
return;
}
//Forums functions
function tp_forums_cleanup()
{
DB()->query('TRUNCATE '. BB_FORUMS);
DB()->query('TRUNCATE ' . BB_FORUMS);
}
function convert_cat($forum, $allow_torrents = true)
{
$forum_data = array(
"forum_id" => $forum['id'],
"cat_id" => $forum['cat_id'],
"forum_name" => $forum['name'],
"forum_order" => $forum['sort'],
"allow_reg_tracker" => $allow_torrents,
"allow_porno_topic" => $allow_torrents,
);
$forum_data = array(
"forum_id" => $forum['id'],
"cat_id" => $forum['cat_id'],
"forum_name" => $forum['name'],
"forum_order" => $forum['sort'],
"allow_reg_tracker" => $allow_torrents,
"allow_porno_topic" => $allow_torrents,
);
$columns = $values = array();
$columns = $values = array();
foreach ($forum_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($forum_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_FORUMS . " ($sql_columns) VALUES($sql_values);");
return;
DB()->query("INSERT IGNORE INTO " . BB_FORUMS . " ($sql_columns) VALUES($sql_values);");
return;
}

View file

@ -1,3 +1,26 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
$passwords = array();
$passwords = array();

View file

@ -1,18 +1,42 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Tracker type
define('TR_TYPE', 'yse'); // 'sky' (SkyTracker) or 'yse' (TBDev YSE)
define('TR_TYPE', 'yse'); // 'sky' (SkyTracker) or 'yse' (TBDev YSE)
// Options
define('CLEAN', true); // Clean TorrentPier's database before converting?
define('CLEAN', true); // Clean TorrentPier's database before converting?
//Users
define('CONVERT_USERS', true); // Converting users is enabled?
define('C_USERS_PER_ONCE', 250); // Number of users converting per once
define('CONVERT_USERS', true); // Converting users is enabled?
define('C_USERS_PER_ONCE', 250); // Number of users converting per once
//Torrents and categories
define('CONVERT_TORRENTS', true); // Converting torrents and categories is enabled?
define('CONVERT_TORRENTS', true); // Converting torrents and categories is enabled?
define('C_TORRENTS_PER_ONCE', 400); // Number of torrents converting per once
define('BDECODE', false); // Recalculate info_hash using bdecode?
define('BDECODE', false); // Recalculate info_hash using bdecode?
//Comments
define('CONVERT_COMMENTS', true); // Converting comments is enabled?
define('CONVERT_COMMENTS', true); // Converting comments is enabled?
define('C_COMMENTS_PER_ONCE', 400); // Number of comments converting per once
//Mybb forums & topics
define('CONVERT_MYBB_FORUMS', false); // Converting forums is enabled?
define('C_FORUMS_PER_ONCE', 100); // Number of forums converting per once
define('C_FORUMS_PER_ONCE', 100); // Number of forums converting per once

View file

@ -1,98 +1,110 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(INC_DIR .'functions_torrent.php');
require(BB_ROOT . 'common.php');
require(INC_DIR . 'functions_torrent.php');
require(BB_ROOT . 'converter/settings.php');
require(BB_ROOT . 'converter/functions.php');
// Init userdata
$user->session_start();
while (@ob_end_flush());
while (@ob_end_flush()) ;
ob_implicit_flush();
?>
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
</head>
<body style="font: 12px Courier, monospace; white-space: nowrap;">
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
</head>
<body style="font: 12px Courier, monospace; white-space: nowrap;">
<?php
if (empty($_POST['confirm']))
{
echo '
if (empty($_POST['confirm'])) {
echo '
<br />
<center>
<form action="'. $_SERVER['PHP_SELF'] .'" method="post">
<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
<input type="submit" name="confirm" value="Recover" />
</form>
</center>
</body>
';
exit;
}
else
{
exit;
} else {
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
$torrents_count = (int)get_count(BB_BT_TORRENTS, 'attach_id');
$loops = (int)ceil($torrents_count / C_TORRENTS_PER_ONCE);
$torrents_count = (int) get_count(BB_BT_TORRENTS, 'attach_id');
$loops = (int) ceil($torrents_count / C_TORRENTS_PER_ONCE);
$not_exist = array();
$not_exist = array();
$attach_dir = get_attachments_dir() . '/';
$attach_dir = get_attachments_dir() .'/';
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
for ($i = 0; $i < $loops; $i++)
{
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
$sql = "SELECT
$sql = "SELECT
tor.attach_id, tor.topic_id, ad.physical_filename
FROM ". BB_BT_TORRENTS ." tor
LEFT JOIN ". BB_ATTACHMENTS_DESC ." ad ON(ad.attach_id = tor.attach_id)
FROM " . BB_BT_TORRENTS . " tor
LEFT JOIN " . BB_ATTACHMENTS_DESC . " ad ON(ad.attach_id = tor.attach_id)
ORDER BY tor.attach_id
LIMIT $start, $offset";
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($torrents as $torrent)
{
$filename = $attach_dir . $torrent['physical_filename'];
if (!file_exists($filename))
{
$not_exist[] = '<a href="viewtopic.php?t='. $torrent['topic_id'] .'">'. $filename .'</a>';
}
else
{
$tor = bdecode_file($filename);
$info = (!empty($tor['info'])) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
foreach ($torrents as $torrent) {
$filename = $attach_dir . $torrent['physical_filename'];
if (!file_exists($filename)) {
$not_exist[] = '<a href="viewtopic.php?t=' . $torrent['topic_id'] . '">' . $filename . '</a>';
} else {
$tor = bdecode_file($filename);
$info = (!empty($tor['info'])) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
DB()->query("UPDATE ". BB_BT_TORRENTS ."
DB()->query("UPDATE " . BB_BT_TORRENTS . "
SET info_hash = '$info_hash_sql'
WHERE attach_id = {$torrent['attach_id']}");
}
}
}
}
}
print_ok("Completed");
if (!empty($not_exist)) {
print_ok("These torrents doesn't exist in filesystem: " . implode(', ', array_unique($not_exist)));
}
}
print_ok ("Completed");
if (!empty($not_exist))
{
print_ok ("These torrents doesn't exist in filesystem: ". implode(', ', array_unique($not_exist)));
}
}

View file

@ -1,8 +1,33 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('EXCLUDED_USERS_CSV')) { define('EXCLUDED_USERS_CSV', join(',', array(GUEST_UID, BOT_UID,))); }
define('TB_USERS_TABLE', 'users');
if (!defined('EXCLUDED_USERS_CSV')) {
define('EXCLUDED_USERS_CSV', join(',', array(GUEST_UID, BOT_UID,)));
}
define('TB_USERS_TABLE', 'users');
define('TB_CATEGORIES_TABLE', 'categories');
define('TB_TORRENTS_TABLE', 'torrents');
define('TB_COMMENTS_TABLE', 'comments');
define('MYBB_FORUMS_TABLE', 'mybb_forums');
define('TB_TORRENTS_TABLE', 'torrents');
define('TB_COMMENTS_TABLE', 'comments');
define('MYBB_FORUMS_TABLE', 'mybb_forums');

View file

@ -1,430 +1,432 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
function print_ok ($sql)
function print_ok($sql)
{
global $err;
global $err;
echo ($err) ? "\n<br />" : '';
$err = '';
echo ($err) ? "\n<br />" : '';
$err = '';
echo '<div>';
echo "<font color=darkgreen><b>OK</b> - $sql</font>". str_repeat(' ', 256) ."\n<br />";
echo '</div>';
echo '<div>';
echo "<font color=darkgreen><b>OK</b> - $sql</font>" . str_repeat(' ', 256) . "\n<br />";
echo '</div>';
}
function hex2bin($h)
{
if (!is_string($h)) return null;
$r='';
for ($a=0; $a<strlen($h); $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); }
return $r;
if (!is_string($h)) return null;
$r = '';
for ($a = 0; $a < strlen($h); $a += 2) {
$r .= chr(hexdec($h{$a} . $h{($a + 1)}));
}
return $r;
}
function get_max_val($table_name, $column)
{
$row = DB()->fetch_row("SELECT MAX($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
$row = DB()->fetch_row("SELECT MAX($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
}
function get_count($table_name, $column)
{
$row = DB()->fetch_row("SELECT COUNT($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
$row = DB()->fetch_row("SELECT COUNT($column) AS $column FROM $table_name LIMIT 1");
return $row[$column];
}
function set_auto_increment($table_name, $column, $val = null)
{
if (empty($val))
{
$row = DB()->fetch_row("SELECT MAX($column) AS val FROM $table_name LIMIT 1");
DB()->sql_freeresult();
$val = (int) $row['val'] + 1;
}
DB()->query("ALTER TABLE $table_name auto_increment = $val");
if (empty($val)) {
$row = DB()->fetch_row("SELECT MAX($column) AS val FROM $table_name LIMIT 1");
DB()->sql_freeresult();
$val = (int)$row['val'] + 1;
}
DB()->query("ALTER TABLE $table_name auto_increment = $val");
}
//Users functions
function tp_users_cleanup()
{
DB()->query('DELETE FROM '. BB_USERS .' WHERE user_id NOT IN('. EXCLUDED_USERS_CSV .')');
DB()->query('TRUNCATE '. BB_BT_USERS);
DB()->query('DELETE FROM ' . BB_USERS . ' WHERE user_id NOT IN(' . EXCLUDED_USERS_CSV . ')');
DB()->query('TRUNCATE ' . BB_BT_USERS);
}
function tp_user_level($tb_class)
{
switch($tb_class)
{
case 0:
case 1:
case 2:
case 3:
$level = 0;
break;
case 4:
$level = 2;
break;
case 5:
case 6:
case 7:
$level = 1;
break;
default:
$level = 0;
break;
}
return $level;
switch ($tb_class) {
case 0:
case 1:
case 2:
case 3:
$level = 0;
break;
case 4:
$level = 2;
break;
case 5:
case 6:
case 7:
$level = 1;
break;
default:
$level = 0;
break;
}
return $level;
}
function convert_user($user)
{
$user_data = array(
"user_id" => $user['id'],
"user_active" => ($user['enabled'] == 'yes') ? true : false,
"username" => $user['username'],
"user_password" => md5($user['password']),
"user_lastvisit" => $user['last_access'],
"user_regdate" => $user['added'],
"user_level" => tp_user_level($user['class']),
"user_lang" => $user['language'],
"user_dateformat" => "Y-m-d H:i",
"user_opt" => $user['opt'], // Added
"user_avatar" => !empty($user['avatar']) ? $user['avatar'] : null,
"user_avatar_type" => !empty($user['avatar']) ? 2 : null,
"user_email" => $user['email'],
"user_website" => $user['website'],
"user_icq" => $user['icq'],
"user_skype" => $user['skype'],
"user_twitter" => $user['twitter'],
"user_gender" => $user['gender'],
"user_birthday" => $user['user_birthday'],
);
$user_data = array(
"user_id" => $user['id'],
"user_active" => ($user['enabled'] == 'yes') ? true : false,
"username" => $user['username'],
"user_password" => md5($user['password']),
"user_lastvisit" => $user['last_access'],
"user_regdate" => $user['added'],
"user_level" => tp_user_level($user['class']),
"user_lang" => $user['language'],
"user_dateformat" => "Y-m-d H:i",
"user_opt" => $user['opt'], // Added
"user_avatar" => !empty($user['avatar']) ? $user['avatar'] : null,
"user_avatar_type" => !empty($user['avatar']) ? 2 : null,
"user_email" => $user['email'],
"user_website" => $user['website'],
"user_icq" => $user['icq'],
"user_skype" => $user['skype'],
"user_twitter" => $user['twitter'],
"user_gender" => $user['gender'],
"user_birthday" => $user['user_birthday'],
);
$columns = $values = array();
$columns = $values = array();
foreach ($user_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_USERS . " ($sql_columns) VALUES ($sql_values);");
DB()->query("INSERT IGNORE INTO " . BB_USERS . " ($sql_columns) VALUES ($sql_values);");
$bt_user_data = array(
"user_id" => $user['id'],
"auth_key" => make_rand_str(BT_AUTH_KEY_LENGTH),
"u_up_total" => $user['uploaded'],
"u_down_total" => $user['downloaded'],
);
$columns = $values = array();
$bt_user_data = array(
"user_id" => $user['id'],
"auth_key" => make_rand_str(BT_AUTH_KEY_LENGTH),
"u_up_total" => $user['uploaded'],
"u_down_total" => $user['downloaded'],
);
$columns = $values = array();
foreach ($bt_user_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
foreach ($bt_user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_BT_USERS . " ($sql_bt_columns) VALUES ($sql_bt_values);");
DB()->query("INSERT IGNORE INTO " . BB_BT_USERS . " ($sql_bt_columns) VALUES ($sql_bt_values);");
}
//Torrents and categories functions
function tp_categories_cleanup()
{
DB()->query('DELETE FROM '. BB_CATEGORIES);
DB()->query('DELETE FROM ' . BB_CATEGORIES);
}
function tp_add_category_old($id, $cat_title)
{
DB()->query("INSERT IGNORE INTO ". BB_CATEGORIES ." (cat_id, cat_title)
VALUES ($id, '". DB()->escape($cat_title) ."')");
return;
DB()->query("INSERT IGNORE INTO " . BB_CATEGORIES . " (cat_id, cat_title)
VALUES ($id, '" . DB()->escape($cat_title) . "')");
return;
}
function tp_add_category($cat_data)
{
$columns = $values = array();
$columns = $values = array();
foreach ($cat_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
foreach ($cat_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_bt_columns = implode(',', $columns);
$sql_bt_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_CATEGORIES . " ($sql_bt_columns) VALUES ($sql_bt_values);");
DB()->query("INSERT IGNORE INTO " . BB_CATEGORIES . " ($sql_bt_columns) VALUES ($sql_bt_values);");
}
function tp_topics_cleanup()
{
DB()->query("TRUNCATE ". BB_ATTACHMENTS);
DB()->query("TRUNCATE ". BB_ATTACHMENTS_DESC);
DB()->query("TRUNCATE ". BB_BT_TORRENTS);
DB()->query("TRUNCATE ". BB_POSTS);
DB()->query("TRUNCATE ". BB_POSTS_HTML);
DB()->query("TRUNCATE ". BB_POSTS_SEARCH);
DB()->query("TRUNCATE ". BB_POSTS_TEXT);
DB()->query("TRUNCATE ". BB_TOPICS);
DB()->query("TRUNCATE " . BB_ATTACHMENTS);
DB()->query("TRUNCATE " . BB_ATTACHMENTS_DESC);
DB()->query("TRUNCATE " . BB_BT_TORRENTS);
DB()->query("TRUNCATE " . BB_POSTS);
DB()->query("TRUNCATE " . BB_POSTS_HTML);
DB()->query("TRUNCATE " . BB_POSTS_SEARCH);
DB()->query("TRUNCATE " . BB_POSTS_TEXT);
DB()->query("TRUNCATE " . BB_TOPICS);
return;
return;
}
function tp_add_topic($topic_data)
{
$columns = $values = array();
foreach ($topic_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
$columns = $values = array();
foreach ($topic_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_TOPICS . " ($sql_columns) VALUES ($sql_values);");
return;
DB()->query("INSERT IGNORE INTO " . BB_TOPICS . " ($sql_columns) VALUES ($sql_values);");
return;
}
function tp_add_post($post_data)
{
foreach ($post_data as $key => $data)
{
$columns = $values = array();
foreach ($data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($post_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES ($sql_values);");
}
return;
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES ($sql_values);");
}
return;
}
function tp_add_attach($attach_data)
{
foreach ($attach_data as $key => $data)
{
$columns = $values = array();
foreach ($data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($attach_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES ($sql_values);");
}
return;
DB()->query("INSERT IGNORE INTO bb_{$key} ($sql_columns) VALUES ($sql_values);");
}
return;
}
function make_img_path ($name)
function make_img_path($name)
{
global $bb_cfg;
global $bb_cfg;
return make_url("files/images/" . $name);
return make_url("files/images/" . $name);
}
function append_images($tor)
{
$poster = $screens = '';
switch(TR_TYPE)
{
case 'yse':
if (!empty($tor['image1']))
{
$poster = "[img=right]".make_img_path($tor['image1'])."[/img]";
}
if (!empty($tor['image2']))
{
$screens = '[spoiler="Скриншоты"][img]'.make_img_path($tor['image2'])."[/img][/spoiler]";
}
break;
case 'sky':
if (!empty($tor['poster']))
{
$poster = "[img=right]".make_img_path($tor['poster'])."[/img]";
}
$has_screens = !empty($tor['screenshot1']) || !empty($tor['screenshot2']) || !empty($tor['screenshot3']) || !empty($tor['screenshot4']);
if ($has_screens)
{
$screens .= '[spoiler="Скриншоты"]';
for ($i = 1; $i <= 4; $i++)
{
if (!empty($tor['screenshot'.$i]))
{
$screens .= "[img]".make_img_path($tor['screenshot'.$i])."[/img] \n";
}
}
$screens .= "[/spoiler]";
}
break;
}
return ($poster . $tor['descr'] . $screens);
$poster = $screens = '';
switch (TR_TYPE) {
case 'yse':
if (!empty($tor['image1'])) {
$poster = "[img=right]" . make_img_path($tor['image1']) . "[/img]";
}
if (!empty($tor['image2'])) {
$screens = '[spoiler="Скриншоты"][img]' . make_img_path($tor['image2']) . "[/img][/spoiler]";
}
break;
case 'sky':
if (!empty($tor['poster'])) {
$poster = "[img=right]" . make_img_path($tor['poster']) . "[/img]";
}
$has_screens = !empty($tor['screenshot1']) || !empty($tor['screenshot2']) || !empty($tor['screenshot3']) || !empty($tor['screenshot4']);
if ($has_screens) {
$screens .= '[spoiler="Скриншоты"]';
for ($i = 1; $i <= 4; $i++) {
if (!empty($tor['screenshot' . $i])) {
$screens .= "[img]" . make_img_path($tor['screenshot' . $i]) . "[/img] \n";
}
}
$screens .= "[/spoiler]";
}
break;
}
return ($poster . $tor['descr'] . $screens);
}
function convert_torrent($torrent)
{
$topic_data = array(
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"topic_title" => $torrent['name'],
"topic_poster" => $torrent['owner'],
"topic_time" => $torrent['added'],
"topic_views" => $torrent['views'],
"topic_type" => ($torrent['sticky'] == 'yes') ? 1 : 0,
"topic_first_post_id" => $torrent['id'],
"topic_last_post_id" => $torrent['id'],
"topic_attachment" => 1,
"topic_dl_type" => 1,
"topic_last_post_time" => $torrent['added'],
);
tp_add_topic($topic_data);
$topic_data = array(
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"topic_title" => $torrent['name'],
"topic_poster" => $torrent['owner'],
"topic_time" => $torrent['added'],
"topic_views" => $torrent['views'],
"topic_type" => ($torrent['sticky'] == 'yes') ? 1 : 0,
"topic_first_post_id" => $torrent['id'],
"topic_last_post_id" => $torrent['id'],
"topic_attachment" => 1,
"topic_dl_type" => 1,
"topic_last_post_time" => $torrent['added'],
);
tp_add_topic($topic_data);
$post_text = stripslashes(prepare_message(addslashes(unprepare_message($torrent['descr'])), true, true));
$post_text = stripslashes(prepare_message(addslashes(unprepare_message($torrent['descr'])), true, true));
$post_data = array(
"posts" => array(
"post_id" => $torrent['post_id'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"poster_id" => $torrent['owner'],
"post_time" => $torrent['added'],
"post_attachment" => 1,
),
"posts_text" => array(
"post_id" => $torrent['post_id'],
"post_text" => $post_text,
),
"posts_search" => array(
"post_id" => $torrent['post_id'],
"search_words" => $torrent['search_text'],
),
);
tp_add_post($post_data);
$post_data = array(
"posts" => array(
"post_id" => $torrent['post_id'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"poster_id" => $torrent['owner'],
"post_time" => $torrent['added'],
"post_attachment" => 1,
),
"posts_text" => array(
"post_id" => $torrent['post_id'],
"post_text" => $post_text,
),
"posts_search" => array(
"post_id" => $torrent['post_id'],
"search_words" => $torrent['search_text'],
),
);
tp_add_post($post_data);
$attach_data = array(
"attachments" => array(
"attach_id" => $torrent['attach_id'],
"post_id" => $torrent['post_id'],
"user_id_1" => $torrent['owner'],
),
"attachments_desc" => array(
"attach_id" => $torrent['attach_id'],
"physical_filename" => $torrent['id'] . ".torrent",
"real_filename" => $torrent['filename'],
"extension" => "torrent",
"mimetype" => "application/x-bittorrent",
"filesize" => @filesize(get_attachments_dir() .'/'. $torrent['id'] .".torrent"),
"filetime" => $torrent['added'],
"tracker_status" => 1,
),
);
tp_add_attach($attach_data);
$attach_data = array(
"attachments" => array(
"attach_id" => $torrent['attach_id'],
"post_id" => $torrent['post_id'],
"user_id_1" => $torrent['owner'],
),
"attachments_desc" => array(
"attach_id" => $torrent['attach_id'],
"physical_filename" => $torrent['id'] . ".torrent",
"real_filename" => $torrent['filename'],
"extension" => "torrent",
"mimetype" => "application/x-bittorrent",
"filesize" => @filesize(get_attachments_dir() . '/' . $torrent['id'] . ".torrent"),
"filetime" => $torrent['added'],
"tracker_status" => 1,
),
);
tp_add_attach($attach_data);
//Torrents
if (BDECODE)
{
$filename = get_attachments_dir() .'/'. $torrent['id'] .".torrent";
if (!file_exists($filename))
{
return;
}
if (!function_exists('bdecode_file')) include_once('./includes/functions_torrent.php');
$tor = bdecode_file($filename);
$info = ($tor['info']) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
}
else
{
$info_hash_sql = hex2bin($torrent['info_hash']);
}
//Torrents
if (BDECODE) {
$filename = get_attachments_dir() . '/' . $torrent['id'] . ".torrent";
if (!file_exists($filename)) {
return;
}
if (!function_exists('bdecode_file')) include_once('./includes/functions_torrent.php');
$tor = bdecode_file($filename);
$info = ($tor['info']) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
} else {
$info_hash_sql = hex2bin($torrent['info_hash']);
}
$torrent_data = array(
"info_hash" => $info_hash_sql,
"post_id" => $torrent['post_id'],
"poster_id" => $torrent['owner'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"attach_id" => $torrent['attach_id'],
"size" => $torrent['size'],
"reg_time" => $torrent['added'],
"complete_count" => $torrent['times_completed'],
"seeder_last_seen" => $torrent['lastseed'],
);
$torrent_data = array(
"info_hash" => $info_hash_sql,
"post_id" => $torrent['post_id'],
"poster_id" => $torrent['owner'],
"topic_id" => $torrent['topic_id'],
"forum_id" => $torrent['category'],
"attach_id" => $torrent['attach_id'],
"size" => $torrent['size'],
"reg_time" => $torrent['added'],
"complete_count" => $torrent['times_completed'],
"seeder_last_seen" => $torrent['lastseed'],
);
$columns = $values = array();
$columns = $values = array();
foreach ($torrent_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(', ', $columns);
$sql_values = implode(', ', $values);
foreach ($torrent_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(', ', $columns);
$sql_values = implode(', ', $values);
DB()->query("INSERT IGNORE INTO ". BB_BT_TORRENTS . " ($sql_columns) VALUES($sql_values);");
return;
DB()->query("INSERT IGNORE INTO " . BB_BT_TORRENTS . " ($sql_columns) VALUES($sql_values);");
return;
}
//Comments functions
function convert_comment($comment)
{
$post_text = prepare_message($comment['text'], true, true);
$post_text = prepare_message($comment['text'], true, true);
$post_data = array(
"posts" => array(
"post_id" => $comment['id'],
"topic_id" => $comment['torrent'],
"forum_id" => $comment['category'],
"poster_id" => $comment['user'],
"post_time" => $comment['added'],
"poster_ip" => encode_ip($comment['ip']),
"post_edit_time" => $comment['editedat'],
"post_edit_count" => $comment['editedat'] ? 1 : 0,
),
"posts_text" => array(
"post_id" => $comment['id'],
"post_text" => $post_text,
),
);
tp_add_post($post_data);
return;
$post_data = array(
"posts" => array(
"post_id" => $comment['id'],
"topic_id" => $comment['torrent'],
"forum_id" => $comment['category'],
"poster_id" => $comment['user'],
"post_time" => $comment['added'],
"poster_ip" => encode_ip($comment['ip']),
"post_edit_time" => $comment['editedat'],
"post_edit_count" => $comment['editedat'] ? 1 : 0,
),
"posts_text" => array(
"post_id" => $comment['id'],
"post_text" => $post_text,
),
);
tp_add_post($post_data);
return;
}
//Forums functions
function tp_forums_cleanup()
{
DB()->query('TRUNCATE '. BB_FORUMS);
DB()->query('TRUNCATE ' . BB_FORUMS);
}
function convert_cat($forum, $allow_torrents = true)
{
$forum_data = array(
"forum_id" => $forum['id'],
"cat_id" => $forum['cat_id'],
"forum_name" => $forum['name'],
"forum_order" => $forum['sort'],
"allow_reg_tracker" => $allow_torrents,
"allow_dl_topic" => $allow_torrents,
);
$forum_data = array(
"forum_id" => $forum['id'],
"cat_id" => $forum['cat_id'],
"forum_name" => $forum['name'],
"forum_order" => $forum['sort'],
"allow_reg_tracker" => $allow_torrents,
"allow_dl_topic" => $allow_torrents,
);
$columns = $values = array();
$columns = $values = array();
foreach ($forum_data as $column => $value)
{
$columns[] = $column;
$values[] = "'". DB()->escape($value) ."'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
foreach ($forum_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
$sql_columns = implode(',', $columns);
$sql_values = implode(',', $values);
DB()->query("INSERT IGNORE INTO ". BB_FORUMS . " ($sql_columns) VALUES ($sql_values);");
return;
DB()->query("INSERT IGNORE INTO " . BB_FORUMS . " ($sql_columns) VALUES ($sql_values);");
return;
}

View file

@ -1,3 +1,26 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
$passwords = array();
$passwords = array();

View file

@ -1,18 +1,42 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Tracker type
define('TR_TYPE', 'yse'); // 'sky' (SkyTracker) or 'yse' (TBDev YSE)
define('TR_TYPE', 'yse'); // 'sky' (SkyTracker) or 'yse' (TBDev YSE)
// Options
define('CLEAN', true); // Clean TorrentPier's database before converting?
define('CLEAN', true); // Clean TorrentPier's database before converting?
//Users
define('CONVERT_USERS', true); // Converting users is enabled?
define('C_USERS_PER_ONCE', 250); // Number of users converting per once
define('CONVERT_USERS', true); // Converting users is enabled?
define('C_USERS_PER_ONCE', 250); // Number of users converting per once
//Torrents and categories
define('CONVERT_TORRENTS', true); // Converting torrents and categories is enabled?
define('CONVERT_TORRENTS', true); // Converting torrents and categories is enabled?
define('C_TORRENTS_PER_ONCE', 400); // Number of torrents converting per once
define('BDECODE', false); // Recalculate info_hash using bdecode?
define('BDECODE', false); // Recalculate info_hash using bdecode?
//Comments
define('CONVERT_COMMENTS', true); // Converting comments is enabled?
define('CONVERT_COMMENTS', true); // Converting comments is enabled?
define('C_COMMENTS_PER_ONCE', 400); // Number of comments converting per once
//Mybb forums & topics
define('CONVERT_MYBB_FORUMS', false); // Converting forums is enabled?
define('C_FORUMS_PER_ONCE', 100); // Number of forums converting per once
define('C_FORUMS_PER_ONCE', 100); // Number of forums converting per once

View file

@ -1,97 +1,109 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
require(BB_ROOT .'common.php');
require(INC_DIR .'functions_torrent.php');
require(BB_ROOT . 'common.php');
require(INC_DIR . 'functions_torrent.php');
require(BB_ROOT . 'converter/settings.php');
require(BB_ROOT . 'converter/functions.php');
// Init userdata
$user->session_start();
while (@ob_end_flush());
while (@ob_end_flush()) ;
ob_implicit_flush();
?><!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
</head>
<body style="font: 12px Courier, monospace; white-space: nowrap;">
<?php
if (empty($_POST['confirm']))
{
echo '
if (empty($_POST['confirm'])) {
echo '
<br />
<center>
<form action="'. $_SERVER['PHP_SELF'] .'" method="post">
<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
<input type="submit" name="confirm" value="Recover" />
</form>
</center>
</body>
';
exit;
}
else
{
exit;
} else {
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
$torrents_count = (int)get_count(BB_BT_TORRENTS, 'attach_id');
$loops = (int)ceil($torrents_count / C_TORRENTS_PER_ONCE);
$torrents_count = (int) get_count(BB_BT_TORRENTS, 'attach_id');
$loops = (int) ceil($torrents_count / C_TORRENTS_PER_ONCE);
$not_exist = array();
$not_exist = array();
$attach_dir = get_attachments_dir() . '/';
$attach_dir = get_attachments_dir() .'/';
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
for ($i = 0; $i < $loops; $i++)
{
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
$sql = "SELECT
$sql = "SELECT
tor.attach_id, tor.topic_id, ad.physical_filename
FROM ". BB_BT_TORRENTS ." tor
LEFT JOIN ". BB_ATTACHMENTS_DESC ." ad ON(ad.attach_id = tor.attach_id)
FROM " . BB_BT_TORRENTS . " tor
LEFT JOIN " . BB_ATTACHMENTS_DESC . " ad ON(ad.attach_id = tor.attach_id)
ORDER BY tor.attach_id
LIMIT $start, $offset";
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($torrents as $torrent)
{
$filename = $attach_dir . $torrent['physical_filename'];
if (!file_exists($filename))
{
$not_exist[] = '<a href="viewtopic.php?t='. $torrent['topic_id'] .'">'. $filename .'</a>';
}
else
{
$tor = bdecode_file($filename);
$info = (!empty($tor['info'])) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
foreach ($torrents as $torrent) {
$filename = $attach_dir . $torrent['physical_filename'];
if (!file_exists($filename)) {
$not_exist[] = '<a href="viewtopic.php?t=' . $torrent['topic_id'] . '">' . $filename . '</a>';
} else {
$tor = bdecode_file($filename);
$info = (!empty($tor['info'])) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
DB()->query("UPDATE ". BB_BT_TORRENTS ."
DB()->query("UPDATE " . BB_BT_TORRENTS . "
SET info_hash = '$info_hash_sql'
WHERE attach_id = {$torrent['attach_id']}");
}
}
}
}
}
print_ok("Completed");
if (!empty($not_exist)) {
print_ok("These torrents doesn't exist in filesystem: " . implode(', ', array_unique($not_exist)));
}
}
print_ok ("Completed");
if (!empty($not_exist))
{
print_ok ("These torrents doesn't exist in filesystem: ". implode(', ', array_unique($not_exist)));
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
@ -7,30 +30,31 @@ require(BB_ROOT . 'common.php');
$user->session_start();
set_die_append_msg();
if (!IS_SUPER_ADMIN) bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$confirm = request_var('confirm', '');
if ($confirm) {
DB()->query("ALTER TABLE ". BB_USERS ." CHANGE COLUMN user_birthday user_birthday_old int(11) NOT NULL DEFAULT 0 AFTER user_gender");
DB()->query("ALTER TABLE ". BB_USERS ." ADD user_birthday date NOT NULL DEFAULT '0000-00-00' AFTER user_gender");
DB()->query("ALTER TABLE " . BB_USERS . " CHANGE COLUMN user_birthday user_birthday_old int(11) NOT NULL DEFAULT 0 AFTER user_gender");
DB()->query("ALTER TABLE " . BB_USERS . " ADD user_birthday date NOT NULL DEFAULT '0000-00-00' AFTER user_gender");
$sql = "SELECT user_id, user_birthday_old FROM ". BB_USERS ." WHERE user_birthday_old != 0 AND user_id NOT IN ('". EXCLUDED_USERS_CSV ."')";
$sql = "SELECT user_id, user_birthday_old FROM " . BB_USERS . " WHERE user_birthday_old != 0 AND user_id NOT IN ('" . EXCLUDED_USERS_CSV . "')";
foreach (DB()->fetch_rowset($sql) as $row)
{
$birthday = bb_date($row['user_birthday_old'] * 86400 + 1, 'Y-m-d', 0);
DB()->query("UPDATE ". BB_USERS ." SET user_birthday = '". $birthday ."' WHERE user_id = ". $row['user_id'] ."");
}
foreach (DB()->fetch_rowset($sql) as $row) {
$birthday = bb_date($row['user_birthday_old'] * 86400 + 1, 'Y-m-d', 0);
DB()->query("UPDATE " . BB_USERS . " SET user_birthday = '" . $birthday . "' WHERE user_id = " . $row['user_id'] . "");
}
DB()->query("ALTER TABLE ". BB_USERS ." DROP user_birthday_old");
DB()->query("ALTER TABLE " . BB_USERS . " DROP user_birthday_old");
bb_die('<h1 style="color: green">База данных обновлена</h1>');
bb_die('<h1 style="color: green">База данных обновлена</h1>');
} else {
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R496)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R496)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
bb_die($msg);
}
bb_die($msg);
}

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
@ -7,12 +30,14 @@ require(BB_ROOT . 'common.php');
$user->session_start();
set_die_append_msg();
if (!IS_SUPER_ADMIN) bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$confirm = request_var('confirm', '');
if ($confirm) {
DB()->query("
DB()->query("
CREATE TEMPORARY TABLE tmp_buf_dlstatus (
user_id mediumint(9) NOT NULL default '0',
topic_id mediumint(8) unsigned NOT NULL default '0',
@ -21,7 +46,7 @@ if ($confirm) {
) ENGINE = MyISAM
");
DB()->query("
DB()->query("
INSERT INTO tmp_buf_dlstatus
(user_id, topic_id, user_status)
SELECT
@ -29,7 +54,7 @@ if ($confirm) {
FROM bb_bt_dlstatus_new
");
DB()->query("
DB()->query("
REPLACE INTO bb_bt_dlstatus_main
(user_id, topic_id, user_status)
SELECT
@ -37,18 +62,18 @@ if ($confirm) {
FROM tmp_buf_dlstatus
");
DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_buf_dlstatus");
DB()->query("RENAME TABLE bb_bt_dlstatus_main TO bb_bt_dlstatus");
DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_buf_dlstatus");
DB()->query("RENAME TABLE bb_bt_dlstatus_main TO bb_bt_dlstatus");
DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_mrg");
DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_new");
DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_mrg");
DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_new");
bb_die('<h1 style="color: green">База данных обновлена</h1>');
bb_die('<h1 style="color: green">База данных обновлена</h1>');
} else {
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R571)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R571)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
bb_die($msg);
}
bb_die($msg);
}

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
@ -7,12 +30,14 @@ require(BB_ROOT . 'common.php');
$user->session_start();
set_die_append_msg();
if (!IS_SUPER_ADMIN) bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$confirm = request_var('confirm', '');
if ($confirm) {
DB()->query("
DB()->query("
CREATE TABLE IF NOT EXISTS `bb_poll_users` (
`topic_id` int(10) unsigned NOT NULL,
`user_id` int(11) NOT NULL,
@ -22,7 +47,7 @@ if ($confirm) {
) ENGINE=MyISAM DEFAULT CHARSET=utf8
");
DB()->query("
DB()->query("
CREATE TABLE IF NOT EXISTS `bb_poll_votes` (
`topic_id` int(10) unsigned NOT NULL,
`vote_id` tinyint(4) unsigned NOT NULL,
@ -32,7 +57,7 @@ if ($confirm) {
) ENGINE=MyISAM DEFAULT CHARSET=utf8
");
DB()->query("
DB()->query("
INSERT IGNORE INTO bb_poll_votes
(topic_id, vote_id, vote_text, vote_result)
SELECT
@ -40,7 +65,7 @@ if ($confirm) {
FROM bb_vote_desc;
");
DB()->query("
DB()->query("
INSERT IGNORE INTO bb_poll_votes
(topic_id, vote_id, vote_text, vote_result)
SELECT
@ -50,7 +75,7 @@ if ($confirm) {
d.vote_id = r.vote_id;
");
DB()->query("
DB()->query("
INSERT IGNORE INTO bb_poll_users
(topic_id, user_id, vote_ip)
SELECT
@ -61,16 +86,16 @@ if ($confirm) {
AND v.vote_user_id > 0;
");
DB()->query("DROP TABLE IF EXISTS bb_vote_desc");
DB()->query("DROP TABLE IF EXISTS bb_vote_results");
DB()->query("DROP TABLE IF EXISTS bb_vote_voters");
DB()->query("DROP TABLE IF EXISTS bb_vote_desc");
DB()->query("DROP TABLE IF EXISTS bb_vote_results");
DB()->query("DROP TABLE IF EXISTS bb_vote_voters");
bb_die('<h1 style="color: green">База данных обновлена</h1>');
bb_die('<h1 style="color: green">База данных обновлена</h1>');
} else {
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R575)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R575)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
bb_die($msg);
}
bb_die($msg);
}

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
@ -13,26 +36,28 @@ ini_set('display_errors', 1);
$user->session_start();
set_die_append_msg();
if (!IS_SUPER_ADMIN) bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$confirm = request_var('confirm', '');
if ($confirm) {
DB()->query("ALTER TABLE " . BB_USERS . " ADD `avatar_ext_id` TINYINT( 4 ) NOT NULL AFTER `user_rank`");
DB()->query("ALTER TABLE " . BB_USERS . " ADD `avatar_ext_id` TINYINT( 4 ) NOT NULL AFTER `user_rank`");
$rows_per_cycle = 10000;
$rows_per_cycle = 10000;
$row = DB()->fetch_row("SELECT MAX(user_id) AS end_id FROM " . BB_USERS);
$end_id = (int)$row['end_id'];
$start = $avatars_ok = $avatars_err = 0;
$row = DB()->fetch_row("SELECT MAX(user_id) AS end_id FROM " . BB_USERS);
$end_id = (int)$row['end_id'];
$start = $avatars_ok = $avatars_err = 0;
echo "<pre>\n";
echo "<pre>\n";
while (true) {
set_time_limit(600);
echo "$start [ $avatars_ok / $avatars_err ]\n";
$end = $start + $rows_per_cycle - 1;
$sql = "
while (true) {
set_time_limit(600);
echo "$start [ $avatars_ok / $avatars_err ]\n";
$end = $start + $rows_per_cycle - 1;
$sql = "
SELECT user_id, avatar_ext_id, user_avatar
FROM " . BB_USERS . "
WHERE user_avatar != ''
@ -41,44 +66,44 @@ if ($confirm) {
ORDER BY NULL
";
foreach (DB()->fetch_rowset($sql) as $row) {
$FILE = array(
'name' => '',
'type' => '',
'size' => 0,
'tmp_name' => BB_ROOT . $bb_cfg['avatar_path'] . '/' . basename($row['user_avatar']),
'error' => 0,
);
$upload = new upload_common();
foreach (DB()->fetch_rowset($sql) as $row) {
$FILE = array(
'name' => '',
'type' => '',
'size' => 0,
'tmp_name' => BB_ROOT . $bb_cfg['avatar_path'] . '/' . basename($row['user_avatar']),
'error' => 0,
);
$upload = new upload_common();
if ($upload->init($bb_cfg['avatars'], $FILE, false) AND $upload->store('avatar', $row)) {
DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = {$upload->file_ext_id} WHERE user_id = {$row['user_id']} LIMIT 1");
$avatars_ok++;
} else {
echo "{$row['user_id']}: ", join("\n{$row['user_id']}: ", $upload->errors), "\n";
$avatars_err++;
}
}
if ($upload->init($bb_cfg['avatars'], $FILE, false) and $upload->store('avatar', $row)) {
DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = {$upload->file_ext_id} WHERE user_id = {$row['user_id']} LIMIT 1");
$avatars_ok++;
} else {
echo "{$row['user_id']}: ", join("\n{$row['user_id']}: ", $upload->errors), "\n";
$avatars_err++;
}
}
if ($end > $end_id) {
break;
}
$start += $rows_per_cycle;
sleep(1);
}
if ($end > $end_id) {
break;
}
$start += $rows_per_cycle;
sleep(1);
}
echo "---------- База данных успешно обновлена. Аватары указанных выше пользователей перенесены не были. ----------\n";
echo "---------- База данных успешно обновлена. Аватары указанных выше пользователей перенесены не были. ----------\n";
DB()->query("ALTER TABLE " . BB_USERS . " DROP `user_avatar`");
DB()->query("ALTER TABLE " . BB_USERS . " DROP `user_avatar_type`");
DB()->query("ALTER TABLE " . BB_USERS . " DROP `user_avatar`");
DB()->query("ALTER TABLE " . BB_USERS . " DROP `user_avatar_type`");
} else {
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">Перед тем как нажать на кнопку, сделайте бекап базы данных! В ходе обновления базы данных, произойдет автоматическая конвертация имеющихся аватаров пользователей
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">Перед тем как нажать на кнопку, сделайте бекап базы данных! В ходе обновления базы данных, произойдет автоматическая конвертация имеющихся аватаров пользователей
по новому алгоритму. Для конвертации аватарка пользователя должна соответствовать текущим значениям из конфига: ширина не более ' . $bb_cfg['avatars']['max_width'] . ' пикселов, высота не более ' . $bb_cfg['avatars']['max_height'] . ' пикселов
и объем не более ' . $bb_cfg['avatars']['max_size'] . ' байт. Если эти условия не соблюдены - аватарка пользователя не будет конвертирована и пользователю придется залить ее заново! Если вы хотите поправить указанные
значения - ПЕРЕД обновлением базы данных сделайте это в config.php!</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R583)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R583)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
bb_die($msg);
}
bb_die($msg);
}

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
@ -12,41 +35,43 @@ ini_set('display_errors', 1);
$user->session_start();
set_die_append_msg();
if (!IS_SUPER_ADMIN) bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$confirm = request_var('confirm', '');
if ($confirm) {
DB()->query("UPDATE " . BB_CONFIG . " SET `config_value` = 'ru' WHERE `config_name` = 'default_lang'");
DB()->query("ALTER TABLE " . BB_USERS . " ADD `user_twitter` varchar (15) NOT NULL DEFAULT '' AFTER `user_skype`");
DB()->query("UPDATE " . BB_CONFIG . " SET `config_value` = 'ru' WHERE `config_name` = 'default_lang'");
DB()->query("ALTER TABLE " . BB_USERS . " ADD `user_twitter` varchar (15) NOT NULL DEFAULT '' AFTER `user_skype`");
$rows_per_cycle = 10000;
$rows_per_cycle = 10000;
$row = DB()->fetch_row("SELECT MAX(user_id) AS end_id FROM " . BB_USERS);
$end_id = (int)$row['end_id'];
$start = 0;
$row = DB()->fetch_row("SELECT MAX(user_id) AS end_id FROM " . BB_USERS);
$end_id = (int)$row['end_id'];
$start = 0;
while (true) {
set_time_limit(600);
$end = $start + $rows_per_cycle - 1;
while (true) {
set_time_limit(600);
$end = $start + $rows_per_cycle - 1;
DB()->query("UPDATE " . BB_USERS . " SET user_lang = 'ru' WHERE user_lang = 'russian'");
DB()->query("UPDATE " . BB_USERS . " SET user_lang = 'en' WHERE user_lang = 'english'");
DB()->query("UPDATE " . BB_USERS . " SET user_lang = 'ru' WHERE user_lang = 'russian'");
DB()->query("UPDATE " . BB_USERS . " SET user_lang = 'en' WHERE user_lang = 'english'");
if ($end > $end_id) {
break;
}
$start += $rows_per_cycle;
sleep(1);
}
if ($end > $end_id) {
break;
}
$start += $rows_per_cycle;
sleep(1);
}
bb_die("База данных успешно обновлена. Можно приступать к обновлению файлов. Не забудьте удалить этот файл.");
bb_die("База данных успешно обновлена. Можно приступать к обновлению файлов. Не забудьте удалить этот файл.");
} else {
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">Перед тем как нажать на кнопку, сделайте бекап базы данных! В ходе обновления базы данных, произойдет автоматическая конвертация текущих языков интерфейса пользователей
$msg = '<form method="POST">';
$msg .= '<h1 style="color: red">Перед тем как нажать на кнопку, сделайте бекап базы данных! В ходе обновления базы данных, произойдет автоматическая конвертация текущих языков интерфейса пользователей
на новое именование, а также будет добавлено поле в базу данных пользователей, для их Twitter-аккаунтов. После этого, вам можно будет приступать к обновлению файлов.</h1><br />';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R588)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
$msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R588)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />';
$msg .= '</form>';
bb_die($msg);
}
bb_die($msg);
}

View file

@ -1,4 +1,27 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_FORUM', true);
define('BB_ROOT', './');
@ -12,7 +35,9 @@ ini_set('display_errors', 1);
$user->session_start();
set_die_append_msg();
if (!IS_SUPER_ADMIN) bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
if (!IS_SUPER_ADMIN) {
bb_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
bb_die('
<h1 style="color: red">Для обновления до стабильной ревизии R600, вам необходимо воспользоваться <a
@ -219,4 +244,4 @@ viewonline.php
Все файлы перекодированы для использования окончаний строк LF.
*/
*/

View file

@ -1,35 +1,57 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $lang, $user;
$mode = (string) $this->request['mode'];
$user_id = (int) $this->request['user_id'];
$mode = (string)$this->request['mode'];
$user_id = (int)$this->request['user_id'];
if (!$user_id OR !$u_data = get_userdata($user_id))
{
$this->ajax_die('Invalid user_id');
if (!$user_id or !$u_data = get_userdata($user_id)) {
$this->ajax_die('Invalid user_id');
}
if (!IS_ADMIN && $user_id != $user->id)
{
$this->ajax_die($lang['NOT_ADMIN']);
if (!IS_ADMIN && $user_id != $user->id) {
$this->ajax_die($lang['NOT_ADMIN']);
}
switch ($mode)
{
case 'delete':
delete_avatar($user_id, $u_data['avatar_ext_id']);
$new_ext_id = 0;
$response = '<img src="'. $bb_cfg['avatars']['upload_path'] . $bb_cfg['avatars']['no_avatar'] .'" alt="'. $user_id .'" />';
break;
default:
$this->ajax_die('Invalid mode');
switch ($mode) {
case 'delete':
delete_avatar($user_id, $u_data['avatar_ext_id']);
$new_ext_id = 0;
$response = '<img src="' . $bb_cfg['avatars']['upload_path'] . $bb_cfg['avatars']['no_avatar'] . '" alt="' . $user_id . '" />';
break;
default:
$this->ajax_die('Invalid mode');
}
DB()->query("UPDATE ". BB_USERS ." SET avatar_ext_id = $new_ext_id WHERE user_id = $user_id LIMIT 1");
DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = $new_ext_id WHERE user_id = $user_id LIMIT 1");
cache_rm_user_sessions($user_id);
$this->response['avatar_html'] = $response;
$this->response['avatar_html'] = $response;

View file

@ -1,106 +1,138 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata, $bb_cfg, $lang;
if (!isset($this->request['attach_id'])) $this->ajax_die($lang['EMPTY_ATTACH_ID']);
if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
$attach_id = (int) $this->request['attach_id'];
$mode = (string) $this->request['mode'];
$attach_id = (int)$this->request['attach_id'];
$mode = (string)$this->request['mode'];
if ($bb_cfg['tor_comment'])
{
$comment = (string) $this->request['comment'];
if ($bb_cfg['tor_comment']) {
$comment = (string)$this->request['comment'];
}
$tor = DB()->fetch_row("
SELECT
tor.poster_id, tor.forum_id, tor.topic_id, tor.tor_status, tor.checked_time, tor.checked_user_id, f.cat_id, t.topic_title
FROM ". BB_BT_TORRENTS ." tor
INNER JOIN ". BB_FORUMS ." f ON(f.forum_id = tor.forum_id)
INNER JOIN ". BB_TOPICS ." t ON(t.topic_id = tor.topic_id)
FROM " . BB_BT_TORRENTS . " tor
INNER JOIN " . BB_FORUMS . " f ON(f.forum_id = tor.forum_id)
INNER JOIN " . BB_TOPICS . " t ON(t.topic_id = tor.topic_id)
WHERE tor.attach_id = $attach_id
LIMIT 1
");
if (!$tor) $this->ajax_die($lang['TORRENT_FAILED']);
switch ($mode)
{
case 'status':
$new_status = (int) $this->request['status'];
// Валидность статуса
if (!isset($lang['TOR_STATUS_NAME'][$new_status])) $this->ajax_die($lang['TOR_STATUS_FAILED']);
if (!isset($this->request['status'])) $this->ajax_die($lang['TOR_DONT_CHANGE']);
if (!IS_AM) $this->ajax_die($lang['NOT_MODERATOR']);
// Тот же статус
if ($tor['tor_status'] == $new_status)
{
$this->ajax_die($lang['TOR_STATUS_DUB']);
}
// Запрет на изменение/присвоение CH-статуса модератором
if ($new_status == TOR_CLOSED_CPHOLD && !IS_ADMIN)
{
$this->ajax_die($lang['TOR_DONT_CHANGE']);
}
// Права на изменение статуса
if ($tor['tor_status'] == TOR_CLOSED_CPHOLD)
{
if (!IS_ADMIN) $this->verify_mod_rights($tor['forum_id']);
DB()->query("UPDATE ". BB_TOPICS ." SET topic_status = ". TOPIC_UNLOCKED ." WHERE topic_id = {$tor['topic_id']} LIMIT 1");
}
else
{
$this->verify_mod_rights($tor['forum_id']);
}
// Подтверждение изменения статуса, выставленного другим модератором
if ($tor['tor_status'] != TOR_NOT_APPROVED && $tor['checked_user_id'] != $userdata['user_id'] && $tor['checked_time'] + 2*3600 > TIMENOW)
{
if (empty($this->request['confirmed']))
{
$msg = $lang['TOR_STATUS_OF'] ." {$lang['TOR_STATUS_NAME'][$tor['tor_status']]}\n\n";
$msg .= ($username = get_username($tor['checked_user_id'])) ? $lang['TOR_STATUS_CHANGED'] . html_entity_decode($username) .", ". delta_time($tor['checked_time']) . $lang['TOR_BACK'] ."\n\n" : "";
$msg .= $lang['PROCEED'] .'?';
$this->prompt_for_confirm($msg);
}
}
change_tor_status($attach_id, $new_status);
$this->response['status'] = $bb_cfg['tor_icons'][$new_status] .' <b> '. $lang['TOR_STATUS_NAME'][$new_status]. '</b> &middot; '. profile_url($userdata) .' &middot; <i>'. delta_time(TIMENOW) . $lang['TOR_BACK']. '</i>';
if ($bb_cfg['tor_comment'] && (($comment && $comment != $lang['COMMENT']) || in_array($new_status, $bb_cfg['tor_reply'])))
{
if ($tor['poster_id'] > 0)
{
$subject = sprintf($lang['TOR_MOD_TITLE'], $tor['topic_title']);
$message = sprintf($lang['TOR_MOD_MSG'], get_username($tor['poster_id']), make_url(TOPIC_URL . $tor['topic_id']), $bb_cfg['tor_icons'][$new_status] .' '.$lang['TOR_STATUS_NAME'][$new_status]);
if ($comment && $comment != $lang['COMMENT']) $message .= "\n\n[b]". $lang['COMMENT'] .'[/b]: '. $comment;
send_pm($tor['poster_id'], $subject, $message, $userdata['user_id']);
cache_rm_user_sessions($tor['poster_id']);
}
}
break;
case 'status_reply':
if (!$bb_cfg['tor_comment']) $this->ajax_die($lang['MODULE_OFF']);
$subject = sprintf($lang['TOR_AUTH_TITLE'], $tor['topic_title']);
$message = sprintf($lang['TOR_AUTH_MSG'], get_username($tor['checked_user_id']), make_url(TOPIC_URL . $tor['topic_id']), $tor['topic_title']);
if ($comment && $comment != $lang['COMMENT']) $message .= "\n\n[b]". $lang['COMMENT'] .'[/b]: '. $comment;
send_pm($tor['checked_user_id'], $subject, $message, $userdata['user_id']);
cache_rm_user_sessions($tor['checked_user_id']);
break;
if (!$tor) {
$this->ajax_die($lang['TORRENT_FAILED']);
}
$this->response['attach_id'] = $attach_id;
switch ($mode) {
case 'status':
$new_status = (int)$this->request['status'];
// Валидность статуса
if (!isset($lang['TOR_STATUS_NAME'][$new_status])) {
$this->ajax_die($lang['TOR_STATUS_FAILED']);
}
if (!isset($this->request['status'])) {
$this->ajax_die($lang['TOR_DONT_CHANGE']);
}
if (!IS_AM) {
$this->ajax_die($lang['NOT_MODERATOR']);
}
// Тот же статус
if ($tor['tor_status'] == $new_status) {
$this->ajax_die($lang['TOR_STATUS_DUB']);
}
// Запрет на изменение/присвоение CH-статуса модератором
if ($new_status == TOR_CLOSED_CPHOLD && !IS_ADMIN) {
$this->ajax_die($lang['TOR_DONT_CHANGE']);
}
// Права на изменение статуса
if ($tor['tor_status'] == TOR_CLOSED_CPHOLD) {
if (!IS_ADMIN) {
$this->verify_mod_rights($tor['forum_id']);
}
DB()->query("UPDATE " . BB_TOPICS . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE topic_id = {$tor['topic_id']} LIMIT 1");
} else {
$this->verify_mod_rights($tor['forum_id']);
}
// Подтверждение изменения статуса, выставленного другим модератором
if ($tor['tor_status'] != TOR_NOT_APPROVED && $tor['checked_user_id'] != $userdata['user_id'] && $tor['checked_time'] + 2 * 3600 > TIMENOW) {
if (empty($this->request['confirmed'])) {
$msg = $lang['TOR_STATUS_OF'] . " {$lang['TOR_STATUS_NAME'][$tor['tor_status']]}\n\n";
$msg .= ($username = get_username($tor['checked_user_id'])) ? $lang['TOR_STATUS_CHANGED'] . html_entity_decode($username) . ", " . delta_time($tor['checked_time']) . $lang['TOR_BACK'] . "\n\n" : "";
$msg .= $lang['PROCEED'] . '?';
$this->prompt_for_confirm($msg);
}
}
change_tor_status($attach_id, $new_status);
$this->response['status'] = $bb_cfg['tor_icons'][$new_status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b> &middot; ' . profile_url($userdata) . ' &middot; <i>' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '</i>';
if ($bb_cfg['tor_comment'] && (($comment && $comment != $lang['COMMENT']) || in_array($new_status, $bb_cfg['tor_reply']))) {
if ($tor['poster_id'] > 0) {
$subject = sprintf($lang['TOR_MOD_TITLE'], $tor['topic_title']);
$message = sprintf($lang['TOR_MOD_MSG'], get_username($tor['poster_id']), make_url(TOPIC_URL . $tor['topic_id']), $bb_cfg['tor_icons'][$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status]);
if ($comment && $comment != $lang['COMMENT']) {
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
}
send_pm($tor['poster_id'], $subject, $message, $userdata['user_id']);
cache_rm_user_sessions($tor['poster_id']);
}
}
break;
case 'status_reply':
if (!$bb_cfg['tor_comment']) {
$this->ajax_die($lang['MODULE_OFF']);
}
$subject = sprintf($lang['TOR_AUTH_TITLE'], $tor['topic_title']);
$message = sprintf($lang['TOR_AUTH_MSG'], get_username($tor['checked_user_id']), make_url(TOPIC_URL . $tor['topic_id']), $tor['topic_title']);
if ($comment && $comment != $lang['COMMENT']) {
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
}
send_pm($tor['checked_user_id'], $subject, $message, $userdata['user_id']);
cache_rm_user_sessions($tor['checked_user_id']);
break;
}
$this->response['attach_id'] = $attach_id;

View file

@ -1,19 +1,42 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata, $bb_cfg, $lang;
if (!isset($this->request['attach_id']))
{
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
if (!isset($this->request['type']))
{
$this->ajax_die('type');
if (!isset($this->request['type'])) {
$this->ajax_die('type');
}
$attach_id = (int) $this->request['attach_id'];
$type = (string) $this->request['type'];
$attach_id = (int)$this->request['attach_id'];
$type = (string)$this->request['type'];
$torrent = DB()->fetch_row("
SELECT
@ -22,11 +45,11 @@ $torrent = DB()->fetch_row("
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
" . 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
@ -36,69 +59,63 @@ $torrent = DB()->fetch_row("
LIMIT 1
");
if (!$torrent) $this->ajax_die($lang['INVALID_ATTACH_ID']);
if ($torrent['poster_id'] == $userdata['user_id'] && !IS_AM)
{
if ($type == 'del_torrent' || $type == 'reg' || $type == 'unreg')
{
true;
}
else
{
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
if (!$torrent) {
$this->ajax_die($lang['INVALID_ATTACH_ID']);
}
elseif (!IS_AM)
{
$this->ajax_die($lang['ONLY_FOR_MOD']);
if ($torrent['poster_id'] == $userdata['user_id'] && !IS_AM) {
if ($type == 'del_torrent' || $type == 'reg' || $type == 'unreg') {
true;
} else {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
} elseif (!IS_AM) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
$title = $url = '';
switch ($type)
{
case 'set_gold';
case 'set_silver';
case 'unset_silver_gold';
if ($type == 'set_silver')
{
$tor_type = TOR_TYPE_SILVER;
}
elseif ($type == 'set_gold')
{
$tor_type = TOR_TYPE_GOLD;
}
else
{
$tor_type = 0;
}
change_tor_type($attach_id, $tor_type);
$title = $lang['CHANGE_TOR_TYPE'];
$url = make_url(TOPIC_URL . $torrent['topic_id']);
break;
switch ($type) {
case 'set_gold';
case 'set_silver';
case 'unset_silver_gold';
if ($type == 'set_silver') {
$tor_type = TOR_TYPE_SILVER;
} elseif ($type == 'set_gold') {
$tor_type = TOR_TYPE_GOLD;
} else {
$tor_type = 0;
}
change_tor_type($attach_id, $tor_type);
$title = $lang['CHANGE_TOR_TYPE'];
$url = make_url(TOPIC_URL . $torrent['topic_id']);
break;
case 'reg';
tracker_register($attach_id);
$url = (TOPIC_URL . $torrent['topic_id']);
break;
case 'reg';
tracker_register($attach_id);
$url = (TOPIC_URL . $torrent['topic_id']);
break;
case 'unreg';
tracker_unregister($attach_id);
$url = (TOPIC_URL . $torrent['topic_id']);
break;
case 'unreg';
tracker_unregister($attach_id);
$url = (TOPIC_URL . $torrent['topic_id']);
break;
case 'del_torrent';
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEL_TORRENT']);
delete_torrent($attach_id);
$url = make_url(TOPIC_URL . $torrent['topic_id']);
break;
case 'del_torrent';
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_TORRENT']);
}
delete_torrent($attach_id);
$url = make_url(TOPIC_URL . $torrent['topic_id']);
break;
case 'del_torrent_move_topic';
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
delete_torrent($attach_id);
$url = make_url("modcp.php?t={$torrent['topic_id']}&mode=move&sid={$userdata['session_id']}");
break;
case 'del_torrent_move_topic';
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
}
delete_torrent($attach_id);
$url = make_url("modcp.php?t={$torrent['topic_id']}&mode=move&sid={$userdata['session_id']}");
break;
}
$this->response['url'] = $url;
$this->response['title'] = $title;
$this->response['url'] = $url;
$this->response['title'] = $title;

View file

@ -1,33 +1,54 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bf, $lang;
$user_id = (int) $this->request['user_id'];
$user_id = (int)$this->request['user_id'];
$new_opt = Zend\Json\Json::decode($this->request['user_opt'], Zend\Json\Json::TYPE_ARRAY);
if (!$user_id OR !$u_data = get_userdata($user_id))
{
$this->ajax_die('invalid user_id');
if (!$user_id or !$u_data = get_userdata($user_id)) {
$this->ajax_die('invalid user_id');
}
if (!is_array($new_opt))
{
$this->ajax_die('invalid new_opt');
if (!is_array($new_opt)) {
$this->ajax_die('invalid new_opt');
}
foreach ($bf['user_opt'] as $opt_name => $opt_bit)
{
if (isset($new_opt[$opt_name]))
{
setbit($u_data['user_opt'], $opt_bit, !empty($new_opt[$opt_name]));
}
foreach ($bf['user_opt'] as $opt_name => $opt_bit) {
if (isset($new_opt[$opt_name])) {
setbit($u_data['user_opt'], $opt_bit, !empty($new_opt[$opt_name]));
}
}
DB()->query("UPDATE ". BB_USERS ." SET user_opt = {$u_data['user_opt']} WHERE user_id = $user_id LIMIT 1");
DB()->query("UPDATE " . BB_USERS . " SET user_opt = {$u_data['user_opt']} WHERE user_id = $user_id LIMIT 1");
// Удаляем данные из кеша
cache_rm_user_sessions ($user_id);
cache_rm_user_sessions($user_id);
$this->response['resp_html'] = $lang['SAVED'];
$this->response['resp_html'] = $lang['SAVED'];

View file

@ -1,27 +1,50 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $datastore, $lang;
$ranks = $datastore->get('ranks');
$ranks = $datastore->get('ranks');
$rank_id = intval($this->request['rank_id']);
if (!$user_id = intval($this->request['user_id']) OR !$profiledata = get_userdata($user_id))
{
$this->ajax_die("invalid user_id: $user_id");
if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) {
$this->ajax_die("invalid user_id: $user_id");
}
if ($rank_id != 0 && !isset($ranks[$rank_id]))
{
$this->ajax_die("invalid rank_id: $rank_id");
if ($rank_id != 0 && !isset($ranks[$rank_id])) {
$this->ajax_die("invalid rank_id: $rank_id");
}
DB()->query("UPDATE ". BB_USERS ." SET user_rank = $rank_id WHERE user_id = $user_id LIMIT 1");
DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id LIMIT 1");
cache_rm_user_sessions($user_id);
$user_rank = ($rank_id) ? '<span class="'. $ranks[$rank_id]['rank_style'] .'">'. $ranks[$rank_id]['rank_title'] .'</span>' : '';
$user_rank = ($rank_id) ? '<span class="' . $ranks[$rank_id]['rank_style'] . '">' . $ranks[$rank_id]['rank_title'] . '</span>' : '';
$this->response['html'] = ($rank_id) ? $lang['AWARDED_RANK'] . "<b> $user_rank </b>" : $lang['SHOT_RANK'];
$this->response['rank_name'] = ($rank_id) ? $user_rank : $lang['USER'];

View file

@ -1,52 +1,73 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $userdata, $lang;
if (!$group_id = intval($this->request['group_id']) OR !$group_info = get_group_data($group_id))
{
$this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']);
if (!$group_id = intval($this->request['group_id']) or !$group_info = get_group_data($group_id)) {
$this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']);
}
if (!$mode = (string) $this->request['mode'])
{
$this->ajax_die('No mode specified');
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('No mode specified');
}
$value = $this->request['value'] = (string) (isset($this->request['value'])) ? $this->request['value'] : 0;
$value = $this->request['value'] = (string)(isset($this->request['value'])) ? $this->request['value'] : 0;
if (!IS_ADMIN && $userdata['user_id'] != $group_info['group_moderator'])
{
$this->ajax_die($lang['ONLY_FOR_MOD']);
if (!IS_ADMIN && $userdata['user_id'] != $group_info['group_moderator']) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
switch ($mode)
{
case 'group_name':
case 'group_signature':
case 'group_description':
$value = htmlCHR($value, false, ENT_NOQUOTES);
$this->response['new_value'] = $value;
break;
switch ($mode) {
case 'group_name':
case 'group_signature':
case 'group_description':
$value = htmlCHR($value, false, ENT_NOQUOTES);
$this->response['new_value'] = $value;
break;
case 'group_type':
$this->response['new_value'] = $value;
break;
case 'group_type':
$this->response['new_value'] = $value;
break;
case 'release_group':
$this->response['new_value'] = $value;
break;
case 'release_group':
$this->response['new_value'] = $value;
break;
case 'delete_avatar':
delete_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']);
$value = 0;
$mode = 'avatar_ext_id';
$this->response['act'] = $value;
break;
case 'delete_avatar':
delete_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']);
$value = 0;
$mode = 'avatar_ext_id';
$this->response['act'] = $value;
break;
default:
$this->ajax_die('Unknown mode');
default:
$this->ajax_die('Unknown mode');
}
$value_sql = DB()->escape($value, true);
DB()->query("UPDATE ". BB_GROUPS ." SET $mode = $value_sql WHERE group_id = $group_id LIMIT 1");
DB()->query("UPDATE " . BB_GROUPS . " SET $mode = $value_sql WHERE group_id = $group_id LIMIT 1");

View file

@ -1,168 +1,181 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $lang;
if (!$user_id = intval($this->request['user_id']) OR !$profiledata = get_userdata($user_id))
{
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) {
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
}
if (!$field = (string) $this->request['field'])
{
$this->ajax_die('invalid profile field');
if (!$field = (string)$this->request['field']) {
$this->ajax_die('invalid profile field');
}
$table = BB_USERS;
$value = $this->request['value'] = (string) (isset($this->request['value'])) ? $this->request['value'] : 0;
$value = $this->request['value'] = (string)(isset($this->request['value'])) ? $this->request['value'] : 0;
switch ($field)
{
case 'username':
require_once(INC_DIR .'functions_validate.php');
$value = clean_username($value);
if ($err = validate_username($value))
{
$this->ajax_die(strip_tags($err));
}
$this->response['new_value'] = $this->request['value'];
break;
switch ($field) {
case 'username':
require_once(INC_DIR . 'functions_validate.php');
$value = clean_username($value);
if ($err = validate_username($value)) {
$this->ajax_die(strip_tags($err));
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_email':
require_once(INC_DIR .'functions_validate.php');
$value = htmlCHR($value);
if ($err = validate_email($value))
{
$this->ajax_die($err);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_email':
require_once(INC_DIR . 'functions_validate.php');
$value = htmlCHR($value);
if ($err = validate_email($value)) {
$this->ajax_die($err);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_website':
if ($value == '' || preg_match('#^https?://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+$#iu', $value))
{
$this->response['new_value'] = htmlCHR($value);
}
else $this->ajax_die($lang['WEBSITE_ERROR']);
break;
case 'user_website':
if ($value == '' || preg_match('#^https?://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+$#iu', $value)) {
$this->response['new_value'] = htmlCHR($value);
} else {
$this->ajax_die($lang['WEBSITE_ERROR']);
}
break;
case 'user_gender':
if (!$bb_cfg['gender']) $this->ajax_die($lang['MODULE_OFF']);
if (!isset($lang['GENDER_SELECT'][$value]))
{
$this->ajax_die($lang['ERROR']);
}
else $this->response['new_value'] = $lang['GENDER_SELECT'][$value];
break;
case 'user_gender':
if (!$bb_cfg['gender']) {
$this->ajax_die($lang['MODULE_OFF']);
}
if (!isset($lang['GENDER_SELECT'][$value])) {
$this->ajax_die($lang['ERROR']);
} else {
$this->response['new_value'] = $lang['GENDER_SELECT'][$value];
}
break;
case 'user_birthday':
if (!$bb_cfg['birthday_enabled']) $this->ajax_die($lang['MODULE_OFF']);
$birthday_date = date_parse($value);
case 'user_birthday':
if (!$bb_cfg['birthday_enabled']) {
$this->ajax_die($lang['MODULE_OFF']);
}
$birthday_date = date_parse($value);
if (!empty($birthday_date['year']))
{
if (strtotime($value) >= TIMENOW)
{
$this->ajax_die($lang['WRONG_BIRTHDAY_FORMAT']);
}
elseif (bb_date(TIMENOW, 'Y', 'false') - $birthday_date['year'] > $bb_cfg['birthday_max_age'])
{
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], $bb_cfg['birthday_max_age']));
}
elseif (bb_date(TIMENOW, 'Y', 'false') - $birthday_date['year'] < $bb_cfg['birthday_min_age'])
{
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], $bb_cfg['birthday_min_age']));
}
}
if (!empty($birthday_date['year'])) {
if (strtotime($value) >= TIMENOW) {
$this->ajax_die($lang['WRONG_BIRTHDAY_FORMAT']);
} elseif (bb_date(TIMENOW, 'Y', 'false') - $birthday_date['year'] > $bb_cfg['birthday_max_age']) {
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], $bb_cfg['birthday_max_age']));
} elseif (bb_date(TIMENOW, 'Y', 'false') - $birthday_date['year'] < $bb_cfg['birthday_min_age']) {
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], $bb_cfg['birthday_min_age']));
}
}
$this->response['new_value'] = $this->request['value'];
break;
$this->response['new_value'] = $this->request['value'];
break;
case 'user_icq':
if ($value && !preg_match('#^\d{6,15}$#', $value))
{
$this->ajax_die($lang['ICQ_ERROR']);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_icq':
if ($value && !preg_match('#^\d{6,15}$#', $value)) {
$this->ajax_die($lang['ICQ_ERROR']);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_skype':
if ($value && !preg_match("#^[a-zA-Z0-9_.\-@,]{6,32}$#", $value))
{
$this->ajax_die($lang['SKYPE_ERROR']);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_skype':
if ($value && !preg_match("#^[a-zA-Z0-9_.\-@,]{6,32}$#", $value)) {
$this->ajax_die($lang['SKYPE_ERROR']);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_twitter':
if ($value && !preg_match("#^[a-zA-Z0-9_]{1,15}$#", $value))
{
$this->ajax_die($lang['TWITTER_ERROR']);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_twitter':
if ($value && !preg_match("#^[a-zA-Z0-9_]{1,15}$#", $value)) {
$this->ajax_die($lang['TWITTER_ERROR']);
}
$this->response['new_value'] = $this->request['value'];
break;
case 'user_from':
case 'user_occ':
case 'user_interests':
$value = htmlCHR($value);
$this->response['new_value'] = $value;
break;
case 'user_from':
case 'user_occ':
case 'user_interests':
$value = htmlCHR($value);
$this->response['new_value'] = $value;
break;
case 'user_regdate':
case 'user_lastvisit':
$tz = TIMENOW + (3600 * $bb_cfg['board_timezone']);
if (($value = strtotime($value, $tz)) < $bb_cfg['board_startdate'] OR $value > TIMENOW)
{
$this->ajax_die($lang['INVALID_DATE'] . $this->request['value']);
}
$this->response['new_value'] = bb_date($value, 'Y-m-d H:i', false);
break;
case 'user_regdate':
case 'user_lastvisit':
$tz = TIMENOW + (3600 * $bb_cfg['board_timezone']);
if (($value = strtotime($value, $tz)) < $bb_cfg['board_startdate'] or $value > TIMENOW) {
$this->ajax_die($lang['INVALID_DATE'] . $this->request['value']);
}
$this->response['new_value'] = bb_date($value, 'Y-m-d H:i', false);
break;
case 'u_up_total':
case 'u_down_total':
case 'u_up_release':
case 'u_up_bonus':
if (!IS_ADMIN) $this->ajax_die($lang['NOT_ADMIN']);
case 'u_up_total':
case 'u_down_total':
case 'u_up_release':
case 'u_up_bonus':
if (!IS_ADMIN) {
$this->ajax_die($lang['NOT_ADMIN']);
}
$table = BB_BT_USERS;
$value = (float) str_replace(',', '.', $this->request['value']);
$table = BB_BT_USERS;
$value = (float)str_replace(',', '.', $this->request['value']);
foreach (array('KB'=>1,'MB'=>2,'GB'=>3,'TB'=>4) as $s => $m)
{
if (strpos($this->request['value'], $s) !== false)
{
$value *= pow(1024, $m);
break;
}
}
$value = sprintf('%.0f', $value);
$this->response['new_value'] = humn_size($value, null, null, ' ');
foreach (array('KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4) as $s => $m) {
if (strpos($this->request['value'], $s) !== false) {
$value *= pow(1024, $m);
break;
}
}
$value = sprintf('%.0f', $value);
$this->response['new_value'] = humn_size($value, null, null, ' ');
if (!$btu = get_bt_userdata($user_id))
{
require(INC_DIR .'functions_torrent.php');
generate_passkey($user_id, true);
$btu = get_bt_userdata($user_id);
}
$btu[$field] = $value;
$this->response['update_ids']['u_ratio'] = (string) get_bt_ratio($btu);
break;
if (!$btu = get_bt_userdata($user_id)) {
require(INC_DIR . 'functions_torrent.php');
generate_passkey($user_id, true);
$btu = get_bt_userdata($user_id);
}
$btu[$field] = $value;
$this->response['update_ids']['u_ratio'] = (string)get_bt_ratio($btu);
break;
case 'user_points':
$value = htmlCHR($value);
$value = (float) str_replace(',', '.', $this->request['value']);
$value = sprintf('%.2f', $value);
$this->response['new_value'] = $value;
break;
case 'user_points':
$value = htmlCHR($value);
$value = (float)str_replace(',', '.', $this->request['value']);
$value = sprintf('%.2f', $value);
$this->response['new_value'] = $value;
break;
default:
$this->ajax_die("invalid profile field: $field");
default:
$this->ajax_die("invalid profile field: $field");
}
$value_sql = DB()->escape($value, true);
DB()->query("UPDATE $table SET $field = $value_sql WHERE user_id = $user_id LIMIT 1");
cache_rm_user_sessions ($user_id);
cache_rm_user_sessions($user_id);
$this->response['edit_id'] = $this->request['edit_id'];
$this->response['edit_id'] = $this->request['edit_id'];

View file

@ -1,25 +1,48 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata, $lang;
$req_uid = (int) $this->request['user_id'];
$req_uid = (int)$this->request['user_id'];
if ($req_uid == $userdata['user_id'] || IS_ADMIN)
{
if (empty($this->request['confirmed']))
{
$this->prompt_for_confirm($lang['BT_GEN_PASSKEY_NEW']);
}
if ($req_uid == $userdata['user_id'] || IS_ADMIN) {
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['BT_GEN_PASSKEY_NEW']);
}
if (!$passkey = generate_passkey($req_uid, IS_ADMIN))
{
$this->ajax_die('Could not insert passkey');
}
if (!$passkey = generate_passkey($req_uid, IS_ADMIN)) {
$this->ajax_die('Could not insert passkey');
}
tracker_rm_user($req_uid);
tracker_rm_user($req_uid);
$this->response['passkey'] = $passkey;
$this->response['passkey'] = $passkey;
} else {
$this->ajax_die($lang['NOT_AUTHORISED']);
}
else $this->ajax_die($lang['NOT_AUTHORISED']);

View file

@ -1,69 +1,82 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $lang, $user;
if (!$user_id = intval($this->request['user_id']) OR !$profiledata = get_userdata($user_id))
{
$this->ajax_die("invalid user_id: $user_id");
if (!$user_id = intval($this->request['user_id']) or !$profiledata = get_userdata($user_id)) {
$this->ajax_die("invalid user_id: $user_id");
}
if (!$mode = (string) $this->request['mode'])
{
$this->ajax_die('invalid mode (empty)');
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
}
switch ($mode)
{
case 'get_group_list':
$sql = "
switch ($mode) {
case 'get_group_list':
$sql = "
SELECT ug.user_pending, g.group_id, g.group_type, g.group_name, g.group_moderator, self.user_id AS can_view
FROM ". BB_USER_GROUP ." ug
INNER JOIN ". BB_GROUPS ." g ON(g.group_id = ug.group_id AND g.group_single_user = 0)
LEFT JOIN ". BB_USER_GROUP ." self ON(self.group_id = g.group_id AND self.user_id = {$user->id} AND self.user_pending = 0)
FROM " . BB_USER_GROUP . " ug
INNER JOIN " . BB_GROUPS . " g ON(g.group_id = ug.group_id AND g.group_single_user = 0)
LEFT JOIN " . BB_USER_GROUP . " self ON(self.group_id = g.group_id AND self.user_id = {$user->id} AND self.user_pending = 0)
WHERE ug.user_id = $user_id
ORDER BY g.group_name
";
$html = array();
foreach (DB()->fetch_rowset($sql) as $row)
{
$class = ($row['user_pending']) ? 'med' : 'med bold';
$class .= ($row['group_moderator'] == $user_id) ? ' colorMod' : '';
$href = "group.php?g={$row['group_id']}";
$html = array();
foreach (DB()->fetch_rowset($sql) as $row) {
$class = ($row['user_pending']) ? 'med' : 'med bold';
$class .= ($row['group_moderator'] == $user_id) ? ' colorMod' : '';
$href = "group.php?g={$row['group_id']}";
if (IS_ADMIN)
{
$href .= "&amp;u=$user_id";
$link = '<a href="'. $href .'" class="'. $class .'" target="_blank">'. htmlCHR($row['group_name']) .'</a>';
$html[] = $link;
}
else
{
// скрытая группа и сам юзер не является ее членом
if ($row['group_type'] == GROUP_HIDDEN && !$row['can_view'])
{
continue;
}
if ($row['group_moderator'] == $user->id)
{
$class .= ' selfMod';
$href .= "&amp;u=$user_id"; // сам юзер модератор этой группы
}
$link = '<a href="'. $href .'" class="'. $class .'" target="_blank">'. htmlCHR($row['group_name']) .'</a>';
$html[] = $link;
}
}
if ($html)
{
$this->response['group_list_html'] = '<ul><li>'. join('</li><li>', $html) .'</li></ul>';
}
else
{
$this->response['group_list_html'] = $lang['GROUP_LIST_HIDDEN'];
}
break;
if (IS_ADMIN) {
$href .= "&amp;u=$user_id";
$link = '<a href="' . $href . '" class="' . $class . '" target="_blank">' . htmlCHR($row['group_name']) . '</a>';
$html[] = $link;
} else {
// скрытая группа и сам юзер не является ее членом
if ($row['group_type'] == GROUP_HIDDEN && !$row['can_view']) {
continue;
}
if ($row['group_moderator'] == $user->id) {
$class .= ' selfMod';
$href .= "&amp;u=$user_id"; // сам юзер модератор этой группы
}
$link = '<a href="' . $href . '" class="' . $class . '" target="_blank">' . htmlCHR($row['group_name']) . '</a>';
$html[] = $link;
}
}
if ($html) {
$this->response['group_list_html'] = '<ul><li>' . join('</li><li>', $html) . '</li></ul>';
} else {
$this->response['group_list_html'] = $lang['GROUP_LIST_HIDDEN'];
}
break;
default:
$this->ajax_die("invalid mode: $mode");
}
default:
$this->ajax_die("invalid mode: $mode");
}

View file

@ -1,132 +1,153 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $lang, $userdata, $datastore;
$mode = (string) $this->request['mode'];
$mode = (string)$this->request['mode'];
$html = '';
switch($mode)
{
case 'birthday_week':
$stats = $datastore->get('stats');
$datastore->enqueue(array(
'stats',
));
switch ($mode) {
case 'birthday_week':
$stats = $datastore->get('stats');
$datastore->enqueue(array(
'stats',
));
if ($stats['birthday_week_list'])
{
foreach($stats['birthday_week_list'] as $week)
{
$html[] = profile_url($week) .' <span class="small">('. birthday_age($week['user_birthday']) .')</span>';
}
$html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $html));
}
else $html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
break;
if ($stats['birthday_week_list']) {
foreach ($stats['birthday_week_list'] as $week) {
$html[] = profile_url($week) . ' <span class="small">(' . birthday_age($week['user_birthday']) . ')</span>';
}
$html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $html));
} else {
$html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
}
break;
case 'birthday_today':
$stats = $datastore->get('stats');
$datastore->enqueue(array(
'stats',
));
case 'birthday_today':
$stats = $datastore->get('stats');
$datastore->enqueue(array(
'stats',
));
if ($stats['birthday_today_list'])
{
foreach($stats['birthday_today_list'] as $today)
{
$html[] = profile_url($today) .' <span class="small">('. birthday_age($today['user_birthday']) .')</span>';
}
$html = $lang['BIRTHDAY_TODAY'] . join(', ', $html);
}
else $html = $lang['NOBIRTHDAY_TODAY'];
break;
if ($stats['birthday_today_list']) {
foreach ($stats['birthday_today_list'] as $today) {
$html[] = profile_url($today) . ' <span class="small">(' . birthday_age($today['user_birthday']) . ')</span>';
}
$html = $lang['BIRTHDAY_TODAY'] . join(', ', $html);
} else {
$html = $lang['NOBIRTHDAY_TODAY'];
}
break;
case 'get_forum_mods':
$forum_id = (int) $this->request['forum_id'];
case 'get_forum_mods':
$forum_id = (int)$this->request['forum_id'];
$datastore->enqueue(array(
'moderators',
));
$datastore->enqueue(array(
'moderators',
));
$moderators = array();
$mod = $datastore->get('moderators');
$moderators = array();
$mod = $datastore->get('moderators');
if (isset($mod['mod_users'][$forum_id]))
{
foreach ($mod['mod_users'][$forum_id] as $user_id)
{
$moderators[] = '<a href="'. PROFILE_URL . $user_id .'">'. $mod['name_users'][$user_id] .'</a>';
}
}
if (isset($mod['mod_users'][$forum_id])) {
foreach ($mod['mod_users'][$forum_id] as $user_id) {
$moderators[] = '<a href="' . PROFILE_URL . $user_id . '">' . $mod['name_users'][$user_id] . '</a>';
}
}
if (isset($mod['mod_groups'][$forum_id]))
{
foreach ($mod['mod_groups'][$forum_id] as $group_id)
{
$moderators[] = '<a href="'. "group.php?". POST_GROUPS_URL ."=". $group_id .'">'. $mod['name_groups'][$group_id] .'</a>';
}
}
if (isset($mod['mod_groups'][$forum_id])) {
foreach ($mod['mod_groups'][$forum_id] as $group_id) {
$moderators[] = '<a href="' . "group.php?" . POST_GROUPS_URL . "=" . $group_id . '">' . $mod['name_groups'][$group_id] . '</a>';
}
}
$html = ':&nbsp;';
$html .= ($moderators) ? join(', ', $moderators) : $lang['NONE'];
unset($moderators, $mod);
$datastore->rm('moderators');
break;
$html = ':&nbsp;';
$html .= ($moderators) ? join(', ', $moderators) : $lang['NONE'];
unset($moderators, $mod);
$datastore->rm('moderators');
break;
case 'change_tz':
$tz = (int) $this->request['tz'];
if ($tz < -12) $tz = -12;
if ($tz > 13) $tz = 13;
if ($tz != $bb_cfg['board_timezone'])
{
// Set current user timezone
DB()->query("UPDATE ". BB_USERS ." SET user_timezone = $tz WHERE user_id = ". $userdata['user_id'] ." LIMIT 1");
$bb_cfg['board_timezone'] = $tz;
cache_rm_user_sessions ($userdata['user_id']);
}
break;
case 'change_tz':
$tz = (int)$this->request['tz'];
if ($tz < -12) {
$tz = -12;
}
if ($tz > 13) {
$tz = 13;
}
if ($tz != $bb_cfg['board_timezone']) {
// Set current user timezone
DB()->query("UPDATE " . BB_USERS . " SET user_timezone = $tz WHERE user_id = " . $userdata['user_id'] . " LIMIT 1");
$bb_cfg['board_timezone'] = $tz;
cache_rm_user_sessions($userdata['user_id']);
}
break;
case 'get_traf_stats':
$user_id = (int) $this->request['user_id'];
$btu = get_bt_userdata($user_id);
$profiledata = get_userdata($user_id);
case 'get_traf_stats':
$user_id = (int)$this->request['user_id'];
$btu = get_bt_userdata($user_id);
$profiledata = get_userdata($user_id);
$speed_up = ($btu['speed_up']) ? humn_size($btu['speed_up']).'/s' : '0 KB/s';
$speed_down = ($btu['speed_down']) ? humn_size($btu['speed_down']).'/s' : '0 KB/s';
$user_ratio = ($btu['u_down_total'] > MIN_DL_FOR_RATIO) ? '<b class="gen">'. get_bt_ratio($btu) .'</b>' : $lang['IT_WILL_BE_DOWN'] .' <b>'. humn_size(MIN_DL_FOR_RATIO) .'</b>';
$speed_up = ($btu['speed_up']) ? humn_size($btu['speed_up']) . '/s' : '0 KB/s';
$speed_down = ($btu['speed_down']) ? humn_size($btu['speed_down']) . '/s' : '0 KB/s';
$user_ratio = ($btu['u_down_total'] > MIN_DL_FOR_RATIO) ? '<b class="gen">' . get_bt_ratio($btu) . '</b>' : $lang['IT_WILL_BE_DOWN'] . ' <b>' . humn_size(MIN_DL_FOR_RATIO) . '</b>';
$html = '
$html = '
<tr class="row3">
<th style="padding: 0;"></th>
<th>'. $lang['DOWNLOADED'] .'</th>
<th>'. $lang['UPLOADED'] .'</th>
<th>'. $lang['RELEASED'] .'</th>
<th>'. $lang['BONUS'] .'</th>';
$html .= ($bb_cfg['seed_bonus_enabled']) ? '<th>'. $lang['SEED_BONUS'] .'</th>' : '';
$html .= '</tr>
<th>' . $lang['DOWNLOADED'] . '</th>
<th>' . $lang['UPLOADED'] . '</th>
<th>' . $lang['RELEASED'] . '</th>
<th>' . $lang['BONUS'] . '</th>';
$html .= ($bb_cfg['seed_bonus_enabled']) ? '<th>' . $lang['SEED_BONUS'] . '</th>' : '';
$html .= '</tr>
<tr class="row1">
<td>'. $lang['TOTAL_TRAF'] .'</td>
<td id="u_down_total"><span class="editable bold leechmed">'. humn_size($btu['u_down_total']) .'</span></td>
<td id="u_up_total"><span class="editable bold seedmed">' .humn_size($btu['u_up_total']) .'</span></td>
<td id="u_up_release"><span class="editable bold seedmed">'. humn_size($btu['u_up_release']) .'</span></td>
<td id="u_up_bonus"><span class="editable bold seedmed">'. humn_size($btu['u_up_bonus']) .'</span></td>';
$html .= ($bb_cfg['seed_bonus_enabled']) ? '<td id="user_points"><span class="editable bold points">'. $profiledata['user_points'] .'</b></td>' : '';
$html .= '</tr>
<td>' . $lang['TOTAL_TRAF'] . '</td>
<td id="u_down_total"><span class="editable bold leechmed">' . humn_size($btu['u_down_total']) . '</span></td>
<td id="u_up_total"><span class="editable bold seedmed">' . humn_size($btu['u_up_total']) . '</span></td>
<td id="u_up_release"><span class="editable bold seedmed">' . humn_size($btu['u_up_release']) . '</span></td>
<td id="u_up_bonus"><span class="editable bold seedmed">' . humn_size($btu['u_up_bonus']) . '</span></td>';
$html .= ($bb_cfg['seed_bonus_enabled']) ? '<td id="user_points"><span class="editable bold points">' . $profiledata['user_points'] . '</b></td>' : '';
$html .= '</tr>
<tr class="row5">
<td colspan="1">'. $lang['MAX_SPEED'] .'</td>
<td colspan="2">'. $lang['DL_DL_SPEED'] .': '. $speed_down .'</span></td>
<td colspan="2">'. $lang['DL_UL_SPEED'] .': '. $speed_up .'</span></td>';
$html .= ($bb_cfg['seed_bonus_enabled']) ? '<td colspan="1"></td>' : '';
$html .= '</tr>';
<td colspan="1">' . $lang['MAX_SPEED'] . '</td>
<td colspan="2">' . $lang['DL_DL_SPEED'] . ': ' . $speed_down . '</span></td>
<td colspan="2">' . $lang['DL_UL_SPEED'] . ': ' . $speed_up . '</span></td>';
$html .= ($bb_cfg['seed_bonus_enabled']) ? '<td colspan="1"></td>' : '';
$html .= '</tr>';
$this->response['user_ratio'] = '
<th><a href="'. $bb_cfg['ratio_url_help'] .'" class="bold">'. $lang['USER_RATIO'] .'</a>:</th>
<td>'. $user_ratio .'</td>
$this->response['user_ratio'] = '
<th><a href="' . $bb_cfg['ratio_url_help'] . '" class="bold">' . $lang['USER_RATIO'] . '</a>:</th>
<td>' . $user_ratio . '</td>
';
break;
break;
}
$this->response['html'] = $html;
$this->response['mode'] = $mode;
$this->response['mode'] = $mode;

View file

@ -1,115 +1,133 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata, $lang, $bb_cfg;
$mode = (string) $this->request['mode'];
$mode = (string)$this->request['mode'];
switch ($mode)
{
case 'clear_cache':
switch ($mode) {
case 'clear_cache':
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val)
{
if (!in_array('db_sqlite', $cache_val))
{
CACHE($cache_name)->rm();
}
}
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) {
if (!in_array('db_sqlite', $cache_val)) {
CACHE($cache_name)->rm();
}
}
$this->response['cache_html'] = '<span class="seed bold">'. $lang['ALL_CACHE_CLEARED'] .'</span>';
$this->response['cache_html'] = '<span class="seed bold">' . $lang['ALL_CACHE_CLEARED'] . '</span>';
break;
break;
case 'clear_datastore':
case 'clear_datastore':
global $datastore;
global $datastore;
$datastore->clean();
$datastore->clean();
$this->response['datastore_html'] = '<span class="seed bold">'. $lang['DATASTORE_CLEARED'] .'</span>';
$this->response['datastore_html'] = '<span class="seed bold">' . $lang['DATASTORE_CLEARED'] . '</span>';
break;
break;
case 'clear_template_cache':
case 'clear_template_cache':
global $template;
global $template;
$match = 'tpl_';
$match_len = strlen($match);
$dir = $template->cachedir;
$res = @opendir($dir);
while (($file = readdir($res)) !== false)
{
if (substr($file, 0, $match_len) === $match)
{
@unlink($dir . $file);
}
}
closedir($res);
$match = 'tpl_';
$match_len = strlen($match);
$dir = $template->cachedir;
$res = @opendir($dir);
while (($file = readdir($res)) !== false) {
if (substr($file, 0, $match_len) === $match) {
@unlink($dir . $file);
}
}
closedir($res);
$this->response['template_cache_html'] = '<span class="seed bold">'. $lang['ALL_TEMPLATE_CLEARED'] .'</span>';
$this->response['template_cache_html'] = '<span class="seed bold">' . $lang['ALL_TEMPLATE_CLEARED'] . '</span>';
break;
break;
case 'indexer':
case 'indexer':
exec("indexer --config {$bb_cfg['sphinx_config_path']} --all --rotate", $result);
exec("indexer --config {$bb_cfg['sphinx_config_path']} --all --rotate", $result);
if (!is_file($bb_cfg['sphinx_config_path'].".log"))
{
file_put_contents($bb_cfg['sphinx_config_path'].".log", "####Logger from dimka3210.####".date("H:i:s", TIMENOW)."##############################\r\n\r\n\r\n\r\n", FILE_APPEND);
}
if (!is_file($bb_cfg['sphinx_config_path'] . ".log")) {
file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "####Logger from dimka3210.####" . date("H:i:s", TIMENOW) . "##############################\r\n\r\n\r\n\r\n", FILE_APPEND);
}
file_put_contents($bb_cfg['sphinx_config_path'].".log", "##############################".date("H:i:s", TIMENOW)."##############################\r\n", FILE_APPEND);
file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "##############################" . date("H:i:s", TIMENOW) . "##############################\r\n", FILE_APPEND);
foreach ($result as $row)
{
file_put_contents($bb_cfg['sphinx_config_path'].".log", $row."\r\n", FILE_APPEND);
}
foreach ($result as $row) {
file_put_contents($bb_cfg['sphinx_config_path'] . ".log", $row . "\r\n", FILE_APPEND);
}
file_put_contents($bb_cfg['sphinx_config_path'].".log", "\r\n", FILE_APPEND);
file_put_contents($bb_cfg['sphinx_config_path'].".log", "\r\n", FILE_APPEND);
file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "\r\n", FILE_APPEND);
file_put_contents($bb_cfg['sphinx_config_path'] . ".log", "\r\n", FILE_APPEND);
$this->response['indexer_html'] = '<span class="seed bold">'. $lang['INDEXER'] .'</span>';
$this->response['indexer_html'] = '<span class="seed bold">' . $lang['INDEXER'] . '</span>';
break;
break;
case 'update_user_level':
case 'update_user_level':
require(INC_DIR .'functions_group.php');
require(INC_DIR . 'functions_group.php');
update_user_level('all');
update_user_level('all');
$this->response['update_user_level_html'] = '<span class="seed bold">'. $lang['USER_LEVELS_UPDATED'] .'</span>';
$this->response['update_user_level_html'] = '<span class="seed bold">' . $lang['USER_LEVELS_UPDATED'] . '</span>';
break;
break;
case 'sync_topics':
case 'sync_topics':
sync('topic', 'all');
sync_all_forums();
sync('topic', 'all');
sync_all_forums();
$this->response['sync_topics_html'] = '<span class="seed bold">'. $lang['TOPICS_DATA_SYNCHRONIZED'] .'</span>';
$this->response['sync_topics_html'] = '<span class="seed bold">' . $lang['TOPICS_DATA_SYNCHRONIZED'] . '</span>';
break;
break;
case 'sync_user_posts':
case 'sync_user_posts':
sync('user_posts', 'all');
sync('user_posts', 'all');
$this->response['sync_user_posts_html'] = '<span class="seed bold">'. $lang['USER_POSTS_COUNT_SYNCHRONIZED'] .'</span>';
$this->response['sync_user_posts_html'] = '<span class="seed bold">' . $lang['USER_POSTS_COUNT_SYNCHRONIZED'] . '</span>';
break;
break;
case 'unlock_cron':
case 'unlock_cron':
cron_enable_board();
cron_enable_board();
$this->response['unlock_cron_html'] = '<span class="seed bold">'. $lang['ADMIN_UNLOCKED'] .'</span>';
$this->response['unlock_cron_html'] = '<span class="seed bold">' . $lang['ADMIN_UNLOCKED'] . '</span>';
break;
break;
}
$this->response['mode'] = $mode;
$this->response['mode'] = $mode;

View file

@ -1,84 +1,126 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata, $lang, $bb_cfg;
$mode = (string) $this->request['mode'];
$mode = (string)$this->request['mode'];
$user_id = $this->request['user_id'];
switch ($mode)
{
case 'delete_profile':
switch ($mode) {
case 'delete_profile':
if ($userdata['user_id'] == $user_id) $this->ajax_die($lang['USER_DELETE_ME']);
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['USER_DELETE_CONFIRM']);
if ($userdata['user_id'] == $user_id) {
$this->ajax_die($lang['USER_DELETE_ME']);
}
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['USER_DELETE_CONFIRM']);
}
if ($user_id != BOT_UID)
{
delete_user_sessions($user_id);
user_delete($user_id);
if ($user_id != BOT_UID) {
delete_user_sessions($user_id);
user_delete($user_id);
$this->response['info'] = $lang['USER_DELETED'];
}
else $this->ajax_die($lang['USER_DELETE_CSV']);
$this->response['info'] = $lang['USER_DELETED'];
} else {
$this->ajax_die($lang['USER_DELETE_CSV']);
}
break;
break;
case 'delete_topics':
case 'delete_topics':
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) $this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DELETE_USER_ALL_POSTS_CONFIRM']);
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) {
$this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
}
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DELETE_USER_ALL_POSTS_CONFIRM']);
}
if (IS_ADMIN)
{
$user_topics = DB()->fetch_rowset("SELECT topic_id FROM ". BB_TOPICS ." WHERE topic_poster = $user_id", 'topic_id');
$deleted_topics = topic_delete($user_topics);
$deleted_posts = post_delete('user', $user_id);
if (IS_ADMIN) {
$user_topics = DB()->fetch_rowset("SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_poster = $user_id", 'topic_id');
$deleted_topics = topic_delete($user_topics);
$deleted_posts = post_delete('user', $user_id);
$this->response['info'] = $lang['USER_DELETED_POSTS'];
}
else $this->ajax_die($lang['NOT_ADMIN']);
$this->response['info'] = $lang['USER_DELETED_POSTS'];
} else {
$this->ajax_die($lang['NOT_ADMIN']);
}
break;
break;
case 'delete_message':
case 'delete_message':
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) $this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DELETE_USER_POSTS_CONFIRM']);
if (empty($this->request['confirmed']) && $userdata['user_id'] == $user_id) {
$this->prompt_for_confirm($lang['DELETE_USER_POSTS_ME']);
}
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DELETE_USER_POSTS_CONFIRM']);
}
if (IS_ADMIN)
{
post_delete('user', $user_id);
if (IS_ADMIN) {
post_delete('user', $user_id);
$this->response['info'] = $lang['USER_DELETED_POSTS'];
}
else $this->ajax_die($lang['NOT_ADMIN']);
$this->response['info'] = $lang['USER_DELETED_POSTS'];
} else {
$this->ajax_die($lang['NOT_ADMIN']);
}
break;
break;
case 'user_activate':
case 'user_activate':
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEACTIVATE_CONFIRM']);
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEACTIVATE_CONFIRM']);
}
DB()->query("UPDATE ". BB_USERS ." SET user_active = '1' WHERE user_id = ". $user_id);
DB()->query("UPDATE " . BB_USERS . " SET user_active = '1' WHERE user_id = " . $user_id);
$this->response['info'] = $lang['USER_ACTIVATE_ON'];
$this->response['info'] = $lang['USER_ACTIVATE_ON'];
break;
break;
case 'user_deactivate':
case 'user_deactivate':
if ($userdata['user_id'] == $user_id) $this->ajax_die($lang['USER_DEACTIVATE_ME']);
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['ACTIVATE_CONFIRM']);
if ($userdata['user_id'] == $user_id) {
$this->ajax_die($lang['USER_DEACTIVATE_ME']);
}
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['ACTIVATE_CONFIRM']);
}
DB()->query("UPDATE ". BB_USERS ." SET user_active = '0' WHERE user_id = ". $user_id);
delete_user_sessions($user_id);
DB()->query("UPDATE " . BB_USERS . " SET user_active = '0' WHERE user_id = " . $user_id);
delete_user_sessions($user_id);
$this->response['info'] = $lang['USER_ACTIVATE_OFF'];
$this->response['info'] = $lang['USER_ACTIVATE_OFF'];
break;
break;
}
$this->response['mode'] = $mode;
$this->response['url'] = html_entity_decode(make_url('/') . PROFILE_URL . $user_id);
$this->response['url'] = html_entity_decode(make_url('/') . PROFILE_URL . $user_id);

View file

@ -1,130 +1,152 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata, $bb_cfg, $lang, $datastore;
$mode = (string) $this->request['mode'];
$mode = (string)$this->request['mode'];
switch ($mode)
{
case 'tor_status':
$topics = (string) $this->request['topic_ids'];
$status = (int) $this->request['status'];
switch ($mode) {
case 'tor_status':
$topics = (string)$this->request['topic_ids'];
$status = (int)$this->request['status'];
// Валидность статуса
if (!isset($lang['TOR_STATUS_NAME'][$status]))
{
$this->ajax_die($lang['STATUS_DOES_EXIST'] . $new_status);
}
// Валидность статуса
if (!isset($lang['TOR_STATUS_NAME'][$status])) {
$this->ajax_die($lang['STATUS_DOES_EXIST'] . $new_status);
}
$topic_ids = DB()->fetch_rowset("SELECT attach_id FROM ". BB_BT_TORRENTS ." WHERE topic_id IN($topics)", 'attach_id');
$topic_ids = DB()->fetch_rowset("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($topics)", 'attach_id');
foreach($topic_ids as $attach_id)
{
change_tor_status($attach_id, $status);
}
$this->response['status'] = $bb_cfg['tor_icons'][$status];
$this->response['topics'] = explode(',', $topics);
break;
foreach ($topic_ids as $attach_id) {
change_tor_status($attach_id, $status);
}
$this->response['status'] = $bb_cfg['tor_icons'][$status];
$this->response['topics'] = explode(',', $topics);
break;
case 'edit_topic_title':
$topic_id = (int) $this->request['topic_id'];
$topic_title = (string) $this->request['topic_title'];
$new_title = clean_title($topic_title);
case 'edit_topic_title':
$topic_id = (int)$this->request['topic_id'];
$topic_title = (string)$this->request['topic_title'];
$new_title = clean_title($topic_title);
if (!$topic_id) $this->ajax_die($lang['INVALID_TOPIC_ID']);
if ($new_title == '') $this->ajax_die($lang['DONT_MESSAGE_TITLE']);
if (!$topic_id) {
$this->ajax_die($lang['INVALID_TOPIC_ID']);
}
if ($new_title == '') {
$this->ajax_die($lang['DONT_MESSAGE_TITLE']);
}
if (!$t_data = DB()->fetch_row("SELECT forum_id FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1"))
{
$this->ajax_die($lang['INVALID_TOPIC_ID_DB']);
}
$this->verify_mod_rights($t_data['forum_id']);
if (!$t_data = DB()->fetch_row("SELECT forum_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1")) {
$this->ajax_die($lang['INVALID_TOPIC_ID_DB']);
}
$this->verify_mod_rights($t_data['forum_id']);
$topic_title_sql = DB()->escape($new_title);
$topic_title_sql = DB()->escape($new_title);
DB()->query("UPDATE ". BB_TOPICS ." SET topic_title = '$topic_title_sql' WHERE topic_id = $topic_id LIMIT 1");
DB()->query("UPDATE " . BB_TOPICS . " SET topic_title = '$topic_title_sql' WHERE topic_id = $topic_id LIMIT 1");
// Обновление кеша новостей на главной
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));
if (isset($news_forums[$t_data['forum_id']]) && $bb_cfg['show_latest_news'])
{
$datastore->enqueue('latest_news');
$datastore->update('latest_news');
}
// Обновление кеша новостей на главной
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));
if (isset($news_forums[$t_data['forum_id']]) && $bb_cfg['show_latest_news']) {
$datastore->enqueue('latest_news');
$datastore->update('latest_news');
}
$net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id']));
if (isset($net_forums[$t_data['forum_id']]) && $bb_cfg['show_network_news'])
{
$datastore->enqueue('network_news');
$datastore->update('network_news');
}
$net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id']));
if (isset($net_forums[$t_data['forum_id']]) && $bb_cfg['show_network_news']) {
$datastore->enqueue('network_news');
$datastore->update('network_news');
}
$this->response['topic_id'] = $topic_id;
$this->response['topic_title'] = $new_title;
break;
$this->response['topic_id'] = $topic_id;
$this->response['topic_title'] = $new_title;
break;
case 'profile_ip':
$user_id = (int) $this->request['user_id'];
$profiledata = get_userdata($user_id);
case 'profile_ip':
$user_id = (int)$this->request['user_id'];
$profiledata = get_userdata($user_id);
if (!$user_id) $this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
if (!$user_id) {
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
}
$reg_ip = DB()->fetch_rowset("SELECT username, user_id, user_rank FROM ". BB_USERS ."
$reg_ip = DB()->fetch_rowset("SELECT username, user_id, user_rank FROM " . BB_USERS . "
WHERE user_reg_ip = '{$profiledata['user_reg_ip']}'
AND user_reg_ip != ''
AND user_id != {$profiledata['user_id']}
ORDER BY username ASC");
$last_ip = DB()->fetch_rowset("SELECT username, user_id, user_rank FROM " .BB_USERS ."
$last_ip = DB()->fetch_rowset("SELECT username, user_id, user_rank FROM " . BB_USERS . "
WHERE user_last_ip = '{$profiledata['user_last_ip']}'
AND user_last_ip != ''
AND user_id != {$profiledata['user_id']}");
$link_reg_ip = $link_last_ip = '';
$link_reg_ip = $link_last_ip = '';
if (!empty($reg_ip))
{
$link_reg_ip .= $lang['OTHER_IP'] .' ';
foreach ($reg_ip as $row)
{
$link_reg_ip .= profile_url($row) .' ';
}
}
if (!empty($reg_ip)) {
$link_reg_ip .= $lang['OTHER_IP'] . ' ';
foreach ($reg_ip as $row) {
$link_reg_ip .= profile_url($row) . ' ';
}
}
if (!empty($last_ip))
{
$link_last_ip .= $lang['OTHER_IP'] .' ';
foreach ($last_ip as $row)
{
$link_last_ip .= profile_url($row) .' ';
}
}
if (!empty($last_ip)) {
$link_last_ip .= $lang['OTHER_IP'] . ' ';
foreach ($last_ip as $row) {
$link_last_ip .= profile_url($row) . ' ';
}
}
if ($profiledata['user_level'] == ADMIN && !IS_ADMIN) $reg_ip = $last_ip = $lang['HIDDEN'];
elseif ($profiledata['user_level'] == MOD && IS_MOD) $reg_ip = $last_ip = $lang['HIDDEN'];
else
{
$user_reg_ip = decode_ip($profiledata['user_reg_ip']);
$user_last_ip = decode_ip($profiledata['user_last_ip']);
$reg_ip = '<a href="'. $bb_cfg['whois_info'] . $user_reg_ip .'" class="gen" target="_blank">'. $user_reg_ip .'</a>';
$last_ip = '<a href="'. $bb_cfg['whois_info'] . $user_last_ip .'" class="gen" target="_blank">'. $user_last_ip .'</a>';
}
if ($profiledata['user_level'] == ADMIN && !IS_ADMIN) {
$reg_ip = $last_ip = $lang['HIDDEN'];
} elseif ($profiledata['user_level'] == MOD && IS_MOD) {
$reg_ip = $last_ip = $lang['HIDDEN'];
} else {
$user_reg_ip = decode_ip($profiledata['user_reg_ip']);
$user_last_ip = decode_ip($profiledata['user_last_ip']);
$reg_ip = '<a href="' . $bb_cfg['whois_info'] . $user_reg_ip . '" class="gen" target="_blank">' . $user_reg_ip . '</a>';
$last_ip = '<a href="' . $bb_cfg['whois_info'] . $user_last_ip . '" class="gen" target="_blank">' . $user_last_ip . '</a>';
}
$this->response['ip_list_html'] = '
$this->response['ip_list_html'] = '
<br /><table class="mod_ip bCenter borderless" cellspacing="1">
<tr class="row5" >
<td>'. $lang['REG_IP'] .'</td>
<td class="tCenter">'. $reg_ip .'</td>
<td><div>'. $link_reg_ip .'</div></td>
<td>' . $lang['REG_IP'] . '</td>
<td class="tCenter">' . $reg_ip . '</td>
<td><div>' . $link_reg_ip . '</div></td>
</tr>
<tr class="row4">
<td>'. $lang['LAST_IP'] .'</td>
<td class="tCenter">'. $last_ip .'</td>
<td><div>'. $link_last_ip .'</div></td>
<td>' . $lang['LAST_IP'] . '</td>
<td class="tCenter">' . $last_ip . '</td>
<td><div>' . $link_last_ip . '</div></td>
</tr>
</table><br />
';
break;
}
break;
}

View file

@ -1,60 +1,87 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $lang, $userdata;
$post_id = (int) $this->request['post_id'];
$mc_type = (int) $this->request['mc_type'];
$mc_text = (string) $this->request['mc_text'];
if (!$mc_text = prepare_message($mc_text)) $this->ajax_die($lang['EMPTY_MESSAGE']);
$post_id = (int)$this->request['post_id'];
$mc_type = (int)$this->request['mc_type'];
$mc_text = (string)$this->request['mc_text'];
if (!$mc_text = prepare_message($mc_text)) {
$this->ajax_die($lang['EMPTY_MESSAGE']);
}
$post = DB()->fetch_row("
SELECT
p.post_id, p.poster_id
FROM ". BB_POSTS ." p
FROM " . BB_POSTS . " p
WHERE p.post_id = $post_id
");
if (!$post) $this->ajax_die('not post');
if (!$post) {
$this->ajax_die('not post');
}
$data = array(
'mc_comment' => ($mc_type) ? $mc_text : '',
'mc_type' => $mc_type,
'mc_user_id' => ($mc_type) ? $userdata['user_id'] : 0,
'mc_comment' => ($mc_type) ? $mc_text : '',
'mc_type' => $mc_type,
'mc_user_id' => ($mc_type) ? $userdata['user_id'] : 0,
);
$sql_args = DB()->build_array('UPDATE', $data);
DB()->query("UPDATE ". BB_POSTS ." SET $sql_args WHERE post_id = $post_id");
DB()->query("UPDATE " . BB_POSTS . " SET $sql_args WHERE post_id = $post_id");
if ($mc_type && $post['poster_id'] != $userdata['user_id'])
{
$subject = sprintf($lang['MC_COMMENT_PM_SUBJECT'], $lang['MC_COMMENT'][$mc_type]['type']);
$message = sprintf($lang['MC_COMMENT_PM_MSG'], get_username($post['poster_id']), make_url(POST_URL ."$post_id#$post_id"), $lang['MC_COMMENT'][$mc_type]['type'], $mc_text);
if ($mc_type && $post['poster_id'] != $userdata['user_id']) {
$subject = sprintf($lang['MC_COMMENT_PM_SUBJECT'], $lang['MC_COMMENT'][$mc_type]['type']);
$message = sprintf($lang['MC_COMMENT_PM_MSG'], get_username($post['poster_id']), make_url(POST_URL . "$post_id#$post_id"), $lang['MC_COMMENT'][$mc_type]['type'], $mc_text);
send_pm($post['poster_id'], $subject, $message);
cache_rm_user_sessions($post['poster_id']);
send_pm($post['poster_id'], $subject, $message);
cache_rm_user_sessions($post['poster_id']);
}
switch($mc_type)
{
case 1: // Комментарий
$mc_class = 'success';
break;
case 2: // Информация
$mc_class = 'info';
break;
case 3: // Предупреждение
$mc_class = 'warning';
break;
case 4: // Нарушение
$mc_class = 'danger';
break;
default:
$mc_class = '';
break;
switch ($mc_type) {
case 1: // Комментарий
$mc_class = 'success';
break;
case 2: // Информация
$mc_class = 'info';
break;
case 3: // Предупреждение
$mc_class = 'warning';
break;
case 4: // Нарушение
$mc_class = 'danger';
break;
default:
$mc_class = '';
break;
}
$this->response['mc_type'] = $mc_type;
$this->response['post_id'] = $post_id;
$this->response['mc_type'] = $mc_type;
$this->response['post_id'] = $post_id;
$this->response['mc_title'] = sprintf($lang['MC_COMMENT'][$mc_type]['title'], profile_url($userdata));
$this->response['mc_text'] = bbcode2html($mc_text);
$this->response['mc_class'] = $mc_class;
$this->response['mc_text'] = bbcode2html($mc_text);
$this->response['mc_class'] = $mc_class;

View file

@ -1,212 +1,212 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $lang, $bb_cfg, $userdata;
if (!isset($this->request['type']))
{
$this->ajax_die('empty type');
if (!isset($this->request['type'])) {
$this->ajax_die('empty type');
}
if (isset($this->request['post_id']))
{
$post_id = (int) $this->request['post_id'];
$post = DB()->fetch_row("SELECT t.*, f.*, p.*, pt.post_text
FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f, ". BB_POSTS ." p, ". BB_POSTS_TEXT ." pt
if (isset($this->request['post_id'])) {
$post_id = (int)$this->request['post_id'];
$post = DB()->fetch_row("SELECT t.*, f.*, p.*, pt.post_text
FROM " . BB_TOPICS . " t, " . BB_FORUMS . " f, " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt
WHERE p.post_id = $post_id
AND t.topic_id = p.topic_id
AND f.forum_id = t.forum_id
AND p.post_id = pt.post_id
LIMIT 1");
if(!$post) $this->ajax_die('not post');
if (!$post) {
$this->ajax_die('not post');
}
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])
{
$this->ajax_die($lang['TOPIC_LOCKED']);
}
}
elseif (isset($this->request['topic_id']))
{
$topic_id = (int) $this->request['topic_id'];
$post = DB()->fetch_row("SELECT t.*, f.*
FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) {
$this->ajax_die($lang['TOPIC_LOCKED']);
}
} elseif (isset($this->request['topic_id'])) {
$topic_id = (int)$this->request['topic_id'];
$post = DB()->fetch_row("SELECT t.*, f.*
FROM " . BB_TOPICS . " t, " . BB_FORUMS . " f
WHERE t.topic_id = $topic_id
AND f.forum_id = t.forum_id
LIMIT 1");
if(!$post) $this->ajax_die('not post');
if (!$post) {
$this->ajax_die('not post');
}
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
}
if (!defined('WORD_LIST_OBTAINED'))
{
$orig_word = array();
$replace_word = array();
obtain_word_list($orig_word, $replace_word);
define('WORD_LIST_OBTAINED', true);
if (!defined('WORD_LIST_OBTAINED')) {
$orig_word = array();
$replace_word = array();
obtain_word_list($orig_word, $replace_word);
define('WORD_LIST_OBTAINED', true);
}
switch($this->request['type'])
{
case 'delete';
if ($post['post_id'] != $post['topic_first_post_id'] && $is_auth['auth_delete'] && ($is_auth['auth_mod'] || ($userdata['user_id'] == $post['poster_id'] && $post['topic_last_post_id'] == $post['post_id'] && $post['post_time'] + 3600*3 > TIMENOW)))
{
if (empty($this->request['confirmed']))
{
$this->prompt_for_confirm($lang['CONFIRM_DELETE']);
}
post_delete($post_id);
switch ($this->request['type']) {
case 'delete';
if ($post['post_id'] != $post['topic_first_post_id'] && $is_auth['auth_delete'] && ($is_auth['auth_mod'] || ($userdata['user_id'] == $post['poster_id'] && $post['topic_last_post_id'] == $post['post_id'] && $post['post_time'] + 3600 * 3 > TIMENOW))) {
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['CONFIRM_DELETE']);
}
post_delete($post_id);
// Update atom feed
update_atom('topic', (int) $this->request['topic_id']);
// Update atom feed
update_atom('topic', (int)$this->request['topic_id']);
$this->response['hide'] = true;
$this->response['post_id'] = $post_id;
}
else
{
$this->ajax_die(sprintf($lang['SORRY_AUTH_DELETE'], strip_tags($is_auth['auth_delete_type'])));
}
break;
$this->response['hide'] = true;
$this->response['post_id'] = $post_id;
} else {
$this->ajax_die(sprintf($lang['SORRY_AUTH_DELETE'], strip_tags($is_auth['auth_delete_type'])));
}
break;
case 'reply';
if (bf($userdata['user_opt'], 'user_opt', 'dis_post'))
{
$this->ajax_die(strip_tags($lang['RULES_REPLY_CANNOT']));
}
elseif(!$is_auth['auth_reply'])
{
$this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type'])));
}
case 'reply';
if (bf($userdata['user_opt'], 'user_opt', 'dis_post')) {
$this->ajax_die(strip_tags($lang['RULES_REPLY_CANNOT']));
} elseif (!$is_auth['auth_reply']) {
$this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type'])));
}
$quote_username = ($post['post_username'] != '') ? $post['post_username'] : get_username($post['poster_id']);
$message = "[quote=\"". $quote_username ."\"][qpost=". $post['post_id'] ."]". $post['post_text'] ."[/quote]\r";
$quote_username = ($post['post_username'] != '') ? $post['post_username'] : get_username($post['poster_id']);
$message = "[quote=\"" . $quote_username . "\"][qpost=" . $post['post_id'] . "]" . $post['post_text'] . "[/quote]\r";
// hide user passkey
$message = preg_replace('#(?<=\?uk=)[a-zA-Z0-9]{10}(?=&)#', 'passkey', $message);
// hide sid
$message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]{12}#', 'sid', $message);
// hide user passkey
$message = preg_replace('#(?<=\?uk=)[a-zA-Z0-9]{10}(?=&)#', 'passkey', $message);
// hide sid
$message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]{12}#', 'sid', $message);
if (!empty($orig_word))
{
$message = (!empty($message)) ? preg_replace($orig_word, $replace_word, $message) : '';
}
if (!empty($orig_word)) {
$message = (!empty($message)) ? preg_replace($orig_word, $replace_word, $message) : '';
}
if ($post['post_id'] == $post['topic_first_post_id'])
{
$message = "[quote]". $post['topic_title'] ."[/quote]\r";
}
if (mb_strlen($message, 'UTF-8') > 1000)
{
$this->response['redirect'] = make_url(POSTING_URL.'?mode=quote&p='. $post_id);
}
if ($post['post_id'] == $post['topic_first_post_id']) {
$message = "[quote]" . $post['topic_title'] . "[/quote]\r";
}
if (mb_strlen($message, 'UTF-8') > 1000) {
$this->response['redirect'] = make_url(POSTING_URL . '?mode=quote&p=' . $post_id);
}
$this->response['quote'] = true;
$this->response['message'] = $message;
break;
$this->response['quote'] = true;
$this->response['message'] = $message;
break;
case 'view_message':
$message = (string) $this->request['message'];
if(!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']);
$message = htmlCHR($message, false, ENT_NOQUOTES);
case 'view_message':
$message = (string)$this->request['message'];
if (!trim($message)) {
$this->ajax_die($lang['EMPTY_MESSAGE']);
}
$message = htmlCHR($message, false, ENT_NOQUOTES);
$this->response['message_html'] = bbcode2html($message);
$this->response['res_id'] = @$this->request['res_id'];
break;
$this->response['message_html'] = bbcode2html($message);
$this->response['res_id'] = @$this->request['res_id'];
break;
case 'edit':
case 'editor':
if (bf($userdata['user_opt'], 'user_opt', 'dis_post_edit'))
{
$this->ajax_die($lang['POST_EDIT_CANNOT']);
}
if ($post['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod'])
{
$this->ajax_die($lang['EDIT_OWN_POSTS']);
}
if ((mb_strlen($post['post_text'], 'UTF-8') > 1000) || $post['post_attachment'] || ($post['topic_first_post_id'] == $post_id))
{
$this->response['redirect'] = make_url(POSTING_URL.'?mode=editpost&p='. $post_id);
}
elseif ($this->request['type'] == 'editor')
{
$text = (string) $this->request['text'];
$text = prepare_message($text);
case 'edit':
case 'editor':
if (bf($userdata['user_opt'], 'user_opt', 'dis_post_edit')) {
$this->ajax_die($lang['POST_EDIT_CANNOT']);
}
if ($post['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod']) {
$this->ajax_die($lang['EDIT_OWN_POSTS']);
}
if ((mb_strlen($post['post_text'], 'UTF-8') > 1000) || $post['post_attachment'] || ($post['topic_first_post_id'] == $post_id)) {
$this->response['redirect'] = make_url(POSTING_URL . '?mode=editpost&p=' . $post_id);
} elseif ($this->request['type'] == 'editor') {
$text = (string)$this->request['text'];
$text = prepare_message($text);
if (mb_strlen($text) > 2)
{
if ($text != $post['post_text'])
{
if ($bb_cfg['max_smilies'])
{
$count_smilies = substr_count(bbcode2html($text), '<img class="smile" src="'. $bb_cfg['smilies_path']);
if ($count_smilies > $bb_cfg['max_smilies'])
{
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
}
}
DB()->query("UPDATE ". BB_POSTS_TEXT ." SET post_text = '". DB()->escape($text) ."' WHERE post_id = $post_id LIMIT 1");
if ($post['topic_last_post_id'] != $post['post_id'] && $userdata['user_id'] == $post['poster_id'])
{
DB()->query("UPDATE ". BB_POSTS ." SET post_edit_time = '". TIMENOW ."', post_edit_count = post_edit_count + 1 WHERE post_id = $post_id LIMIT 1");
}
$s_text = str_replace('\n', "\n", $text);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
add_search_words($post_id, stripslashes($s_text), stripslashes($s_topic_title));
update_post_html(array(
'post_id' => $post_id,
'post_text' => $text,
));
}
}
else $this->ajax_die($lang['EMPTY_MESSAGE']);
if (mb_strlen($text) > 2) {
if ($text != $post['post_text']) {
if ($bb_cfg['max_smilies']) {
$count_smilies = substr_count(bbcode2html($text), '<img class="smile" src="' . $bb_cfg['smilies_path']);
if ($count_smilies > $bb_cfg['max_smilies']) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
}
}
DB()->query("UPDATE " . BB_POSTS_TEXT . " SET post_text = '" . DB()->escape($text) . "' WHERE post_id = $post_id LIMIT 1");
if ($post['topic_last_post_id'] != $post['post_id'] && $userdata['user_id'] == $post['poster_id']) {
DB()->query("UPDATE " . BB_POSTS . " SET post_edit_time = '" . TIMENOW . "', post_edit_count = post_edit_count + 1 WHERE post_id = $post_id LIMIT 1");
}
$s_text = str_replace('\n', "\n", $text);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
add_search_words($post_id, stripslashes($s_text), stripslashes($s_topic_title));
update_post_html(array(
'post_id' => $post_id,
'post_text' => $text,
));
}
} else {
$this->ajax_die($lang['EMPTY_MESSAGE']);
}
// Update atom feed
update_atom('topic', (int) $this->request['topic_id']);
// Update atom feed
update_atom('topic', (int)$this->request['topic_id']);
$this->response['html'] = bbcode2html($text);
}
else
{
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])
{
$this->ajax_die($lang['TOPIC_LOCKED']);
}
elseif (!$is_auth['auth_edit'])
{
$this->ajax_die(sprintf($lang['SORRY_AUTH_EDIT'], strip_tags($is_auth['auth_edit_type'])));
}
$this->response['html'] = bbcode2html($text);
} else {
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) {
$this->ajax_die($lang['TOPIC_LOCKED']);
} elseif (!$is_auth['auth_edit']) {
$this->ajax_die(sprintf($lang['SORRY_AUTH_EDIT'], strip_tags($is_auth['auth_edit_type'])));
}
$hidden_form = '<input type="hidden" name="mode" value="editpost" />';
$hidden_form .= '<input type="hidden" name="'. POST_POST_URL .'" value="'. $post_id .'" />';
$hidden_form .= '<input type="hidden" name="subject" value="'. $post['topic_title'] .'" />';
$hidden_form = '<input type="hidden" name="mode" value="editpost" />';
$hidden_form .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
$hidden_form .= '<input type="hidden" name="subject" value="' . $post['topic_title'] . '" />';
$this->response['text'] = '
<form action="'. POSTING_URL .'" method="post" name="post">
'. $hidden_form .'
$this->response['text'] = '
<form action="' . POSTING_URL . '" method="post" name="post">
' . $hidden_form . '
<div class="buttons mrg_4">
<input type="button" value="B" name="codeB" title="'. $lang['BOLD'] .'" style="font-weight: bold; width: 25px;" />
<input type="button" value="i" name="codeI" title="'. $lang['ITALIC'] .'" style="width: 25px; font-style: italic;" />
<input type="button" value="u" name="codeU" title="'. $lang['UNDERLINE'] .'" style="width: 25px; text-decoration: underline;" />
<input type="button" value="s" name="codeS" title="'. $lang['STRIKEOUT'] .'" style="width: 25px; text-decoration: line-through;" />&nbsp;&nbsp;
<input type="button" value="'. $lang['QUOTE'] .'" name="codeQuote" title="'. $lang['QUOTE_TITLE'] .'" style="width: 57px;" />
<input type="button" value="Img" name="codeImg" title="'. $lang['IMG_TITLE'] .'" style="width: 40px;" />
<input type="button" value="'. $lang['URL'] .'" name="codeUrl" title="'. $lang['URL_TITLE'] .'" style="width: 63px; text-decoration: underline;" />&nbsp;
<input type="button" value="'. $lang['CODE'] .'" name="codeCode" title="'. $lang['CODE_TITLE'] .'" style="width: 43px;" />
<input type="button" value="'. $lang['LIST'] .'" name="codeList" title="'. $lang['LIST_TITLE'] .'" style="width: 60px;" />
<input type="button" value="1." name="codeOpt" title="'. $lang['LIST_ITEM'] .'" style="width: 30px;" />&nbsp;
<input type="button" value="'. $lang['QUOTE_SEL'] .'" name="quoteselected" title="'. $lang['QUOTE_SELECTED'] .'" onclick="bbcode.onclickQuoteSel();" />&nbsp;
<input type="button" value="B" name="codeB" title="' . $lang['BOLD'] . '" style="font-weight: bold; width: 25px;" />
<input type="button" value="i" name="codeI" title="' . $lang['ITALIC'] . '" style="width: 25px; font-style: italic;" />
<input type="button" value="u" name="codeU" title="' . $lang['UNDERLINE'] . '" style="width: 25px; text-decoration: underline;" />
<input type="button" value="s" name="codeS" title="' . $lang['STRIKEOUT'] . '" style="width: 25px; text-decoration: line-through;" />&nbsp;&nbsp;
<input type="button" value="' . $lang['QUOTE'] . '" name="codeQuote" title="' . $lang['QUOTE_TITLE'] . '" style="width: 57px;" />
<input type="button" value="Img" name="codeImg" title="' . $lang['IMG_TITLE'] . '" style="width: 40px;" />
<input type="button" value="' . $lang['URL'] . '" name="codeUrl" title="' . $lang['URL_TITLE'] . '" style="width: 63px; text-decoration: underline;" />&nbsp;
<input type="button" value="' . $lang['CODE'] . '" name="codeCode" title="' . $lang['CODE_TITLE'] . '" style="width: 43px;" />
<input type="button" value="' . $lang['LIST'] . '" name="codeList" title="' . $lang['LIST_TITLE'] . '" style="width: 60px;" />
<input type="button" value="1." name="codeOpt" title="' . $lang['LIST_ITEM'] . '" style="width: 30px;" />&nbsp;
<input type="button" value="' . $lang['QUOTE_SEL'] . '" name="quoteselected" title="' . $lang['QUOTE_SELECTED'] . '" onclick="bbcode.onclickQuoteSel();" />&nbsp;
</div>
<textarea id="message-'. $post_id .'" class="editor mrg_4" name="message" rows="18" cols="92">'. $post['post_text'] .'</textarea>
<textarea id="message-' . $post_id . '" class="editor mrg_4" name="message" rows="18" cols="92">' . $post['post_text'] . '</textarea>
<div class="mrg_4 tCenter">
<input title="Alt+Enter" name="preview" type="submit" value="'. $lang['PREVIEW'] .'">
<input type="button" onclick="edit_post('. $post_id .');" value="'. $lang['CANCEL'] .'">
<input type="button" onclick="edit_post('. $post_id .', \'editor\', $(\'#message-'. $post_id .'\').val()); return false;" class="bold" value="'. $lang['SUBMIT'] .'">
<input title="Alt+Enter" name="preview" type="submit" value="' . $lang['PREVIEW'] . '">
<input type="button" onclick="edit_post(' . $post_id . ');" value="' . $lang['CANCEL'] . '">
<input type="button" onclick="edit_post(' . $post_id . ', \'editor\', $(\'#message-' . $post_id . '\').val()); return false;" class="bold" value="' . $lang['SUBMIT'] . '">
</div><hr>
<script type="text/javascript">
var bbcode = new BBCode("message-'. $post_id .'");
var bbcode = new BBCode("message-' . $post_id . '");
var ctrl = "ctrl";
bbcode.addTag("codeB", "b", null, "B", ctrl);
@ -223,106 +223,92 @@ switch($this->request['type'])
bbcode.addTag("codeOpt", "*", "", "0", ctrl);
</script>
</form>';
}
$this->response['post_id'] = $post_id;
break;
}
$this->response['post_id'] = $post_id;
break;
case 'add':
if (!isset($this->request['topic_id']))
{
$this->ajax_die('empty topic_id');
}
case 'add':
if (!isset($this->request['topic_id'])) {
$this->ajax_die('empty topic_id');
}
if (bf($userdata['user_opt'], 'user_opt', 'dis_post'))
{
$this->ajax_die(strip_tags($lang['RULES_REPLY_CANNOT']));
}
elseif (!$is_auth['auth_reply'])
{
$this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type'])));
}
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])
{
$this->ajax_die($lang['TOPIC_LOCKED']);
}
if (bf($userdata['user_opt'], 'user_opt', 'dis_post')) {
$this->ajax_die(strip_tags($lang['RULES_REPLY_CANNOT']));
} elseif (!$is_auth['auth_reply']) {
$this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type'])));
}
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) {
$this->ajax_die($lang['TOPIC_LOCKED']);
}
$message = (string) $this->request['message'];
$message = prepare_message($message);
$message = (string)$this->request['message'];
$message = prepare_message($message);
// Flood control
$where_sql = (IS_GUEST) ? "p.poster_ip = '". USER_IP ."'" : "p.poster_id = {$userdata['user_id']}";
// Flood control
$where_sql = (IS_GUEST) ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}";
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM ". BB_POSTS ." p WHERE $where_sql";
if ($row = DB()->fetch_row($sql) AND $row['last_post_time'])
{
if ($userdata['user_level'] == USER)
{
if (TIMENOW - $row['last_post_time'] < $bb_cfg['flood_interval'])
{
$this->ajax_die($lang['FLOOD_ERROR']);
}
}
}
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql";
if ($row = DB()->fetch_row($sql) and $row['last_post_time']) {
if ($userdata['user_level'] == USER) {
if (TIMENOW - $row['last_post_time'] < $bb_cfg['flood_interval']) {
$this->ajax_die($lang['FLOOD_ERROR']);
}
}
}
// Double Post Control
if (!empty($row['last_post_time']) && !IS_AM)
{
$sql = "
// Double Post Control
if (!empty($row['last_post_time']) && !IS_AM) {
$sql = "
SELECT pt.post_text
FROM ". BB_POSTS ." p, ". BB_POSTS_TEXT ." pt
FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt
WHERE $where_sql
AND p.post_time = ". (int) $row['last_post_time'] ."
AND p.post_time = " . (int)$row['last_post_time'] . "
AND pt.post_id = p.post_id
LIMIT 1
";
if ($row = DB()->fetch_row($sql))
{
$last_msg = DB()->escape($row['post_text']);
if ($row = DB()->fetch_row($sql)) {
$last_msg = DB()->escape($row['post_text']);
if ($last_msg == $message)
{
$this->ajax_die($lang['DOUBLE_POST_ERROR']);
}
}
}
if ($last_msg == $message) {
$this->ajax_die($lang['DOUBLE_POST_ERROR']);
}
}
}
if ($bb_cfg['max_smilies'])
{
$count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="'. $bb_cfg['smilies_path']);
if ($count_smilies > $bb_cfg['max_smilies'])
{
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
}
}
if ($bb_cfg['max_smilies']) {
$count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . $bb_cfg['smilies_path']);
if ($count_smilies > $bb_cfg['max_smilies']) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
}
}
DB()->sql_query("INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ($topic_id, ". $post['forum_id'] .", ". $userdata['user_id'] .", '". TIMENOW ."', '". USER_IP ."')");
$post_id = DB()->sql_nextid();
DB()->sql_query("INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '". DB()->escape($message) ."')");
DB()->sql_query("INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ($topic_id, " . $post['forum_id'] . ", " . $userdata['user_id'] . ", '" . TIMENOW . "', '" . USER_IP . "')");
$post_id = DB()->sql_nextid();
DB()->sql_query("INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '" . DB()->escape($message) . "')");
update_post_stats('reply', $post, $post['forum_id'], $topic_id, $post_id, $userdata['user_id']);
update_post_stats('reply', $post, $post['forum_id'], $topic_id, $post_id, $userdata['user_id']);
$s_message = str_replace('\n', "\n", $message);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
add_search_words($post_id, stripslashes($s_message), stripslashes($s_topic_title));
update_post_html(array(
'post_id' => $post_id,
'post_text' => $message,
));
$s_message = str_replace('\n', "\n", $message);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
add_search_words($post_id, stripslashes($s_message), stripslashes($s_topic_title));
update_post_html(array(
'post_id' => $post_id,
'post_text' => $message,
));
if ($bb_cfg['topic_notify_enabled'])
{
$notify = !empty($this->request['notify']);
user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify);
}
if ($bb_cfg['topic_notify_enabled']) {
$notify = !empty($this->request['notify']);
user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify);
}
// Update atom feed
update_atom('topic', (int) $this->request['topic_id']);
// Update atom feed
update_atom('topic', (int)$this->request['topic_id']);
$this->response['redirect'] = make_url(POST_URL . "$post_id#$post_id");
break;
$this->response['redirect'] = make_url(POST_URL . "$post_id#$post_id");
break;
default:
$this->ajax_die('empty type');
break;
}
default:
$this->ajax_die('empty type');
break;
}

View file

@ -1,55 +1,80 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $lang;
$mode = (string) $this->request['mode'];
$map = new sitemap();
$mode = (string)$this->request['mode'];
$map = new sitemap();
$html = '';
switch ($mode)
{
case 'create':
$map->create();
if (@file_exists(SITEMAP_DIR. 'sitemap.xml'))
{
$html .= $lang['SITEMAP_CREATED'].': <b>'.bb_date(TIMENOW, $bb_cfg['post_date_format']).'</b> '.$lang['SITEMAP_AVAILABLE'].': <a href="'.make_url('sitemap.xml').'" target="_blank">'.make_url('sitemap.xml').'</a>';
} else {
$html .= $lang['SITEMAP_NOT_CREATED'];
}
break;
switch ($mode) {
case 'create':
$map->create();
if (@file_exists(SITEMAP_DIR . 'sitemap.xml')) {
$html .= $lang['SITEMAP_CREATED'] . ': <b>' . bb_date(TIMENOW, $bb_cfg['post_date_format']) . '</b> ' . $lang['SITEMAP_AVAILABLE'] . ': <a href="' . make_url('sitemap.xml') . '" target="_blank">' . make_url('sitemap.xml') . '</a>';
} else {
$html .= $lang['SITEMAP_NOT_CREATED'];
}
break;
case 'search_update':
if (!@file_exists(SITEMAP_DIR. 'sitemap.xml')) $map->create();
case 'search_update':
if (!@file_exists(SITEMAP_DIR . 'sitemap.xml')) {
$map->create();
}
$map_link = make_url(SITEMAP_DIR. 'sitemap.xml');
$map_link = make_url(SITEMAP_DIR . 'sitemap.xml');
if (strpos($map->send_url("http://google.com/webmasters/sitemaps/ping?sitemap=", $map_link), "successfully added") !== false) {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Google: <font style="color: green;">'.$lang['SITEMAP_SENT'].'</font>';
} else {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Google: <font style="color: red;">'.$lang['SITEMAP_ERROR'].'</font> URL: <a href="http://google.com/webmasters/sitemaps/ping?sitemap='.urlencode($map_link).'" target="_blank">http://google.com/webmasters/sitemaps/ping?sitemap='.$map_link.'</a>';
}
if (strpos($map->send_url("http://google.com/webmasters/sitemaps/ping?sitemap=", $map_link), "successfully added") !== false) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://google.com/webmasters/sitemaps/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://google.com/webmasters/sitemaps/ping?sitemap=' . $map_link . '</a>';
}
if (strpos($map->send_url("http://ping.blogs.yandex.ru/ping?sitemap=", $map_link), "OK") !== false) {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Yandex: <font style="color: green;">'.$lang['SITEMAP_SENT'].'</font>';
} else {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Yandex: <font style="color: red;">'.$lang['SITEMAP_ERROR'].'</font> URL: <a href="http://ping.blogs.yandex.ru/ping?sitemap='.urlencode($map_link).'" target="_blank">http://ping.blogs.yandex.ru/ping?sitemap='.$map_link.'</a>';
}
if (strpos($map->send_url("http://ping.blogs.yandex.ru/ping?sitemap=", $map_link), "OK") !== false) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://ping.blogs.yandex.ru/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://ping.blogs.yandex.ru/ping?sitemap=' . $map_link . '</a>';
}
if ($map->send_url("http://www.bing.com/ping?sitemap=", $map_link)) {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Bing: <font style="color: green;">'.$lang['SITEMAP_SENT'].'</font>';
} else {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Bing: <font style="color: red;">'.$lang['SITEMAP_ERROR'].'</font> URL: <a href="http://www.bing.com/ping?sitemap='.urlencode($map_link).'" target="_blank">http://www.bing.com/ping?sitemap='.$map_link.'</a>';
}
if ($map->send_url("http://www.bing.com/ping?sitemap=", $map_link)) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://www.bing.com/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://www.bing.com/ping?sitemap=' . $map_link . '</a>';
}
if (strpos($map->send_url("http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=", $map_link), "Thanks for the ping") !== false) {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Weblogs: <font style="color: green;">'.$lang['SITEMAP_SENT'].'</font>';
} else {
$html .= '<br />'.$lang['SITEMAP_NOTIFY_SEARCH'].' Weblogs: <font style="color: red;">'.$lang['SITEMAP_ERROR'].'</font> URL: <a href="http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url='.urlencode($map_link).'" target="_blank">http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url='.$map_link.'</a>';
}
break;
if (strpos($map->send_url("http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=", $map_link), "Thanks for the ping") !== false) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . urlencode($map_link) . '" target="_blank">http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . $map_link . '</a>';
}
break;
}
$this->response['html'] = $html;
$this->response['mode'] = $mode;
$this->response['mode'] = $mode;

View file

@ -1,172 +1,180 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata;
if (!IS_SUPER_ADMIN) $this->ajax_die('not auth');
if (!IS_SUPER_ADMIN) {
$this->ajax_die('not auth');
}
array_deep($this->request, 'trim');
$mode = (string) $this->request['mode'];
$mode = (string)$this->request['mode'];
$sql_error = false;
// установка / начальная валидация значений
switch ($mode)
{
case 'load':
case 'save':
if (!$tpl_id = (int) $this->request['tpl_id'])
{
$this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)');
}
if (!$tpl_data = DB()->fetch_row("SELECT * FROM ". BB_TOPIC_TPL ." WHERE tpl_id = $tpl_id LIMIT 1"))
{
$this->ajax_die("Шаблон [id: $tpl_id] не найден в БД");
}
break;
switch ($mode) {
case 'load':
case 'save':
if (!$tpl_id = (int)$this->request['tpl_id']) {
$this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)');
}
if (!$tpl_data = DB()->fetch_row("SELECT * FROM " . BB_TOPIC_TPL . " WHERE tpl_id = $tpl_id LIMIT 1")) {
$this->ajax_die("Шаблон [id: $tpl_id] не найден в БД");
}
break;
}
switch ($mode)
{
case 'save':
case 'new':
if (!$tpl_name = htmlCHR(str_compact($this->request['tpl_name'])))
{
$this->ajax_die('не заполнено название шаблона');
}
$tpl_name = substr($tpl_name, 0, 60);
switch ($mode) {
case 'save':
case 'new':
if (!$tpl_name = htmlCHR(str_compact($this->request['tpl_name']))) {
$this->ajax_die('не заполнено название шаблона');
}
$tpl_name = substr($tpl_name, 0, 60);
if (!$tpl_src_form = htmlCHR($this->request['tpl_src_form']))
{
$this->ajax_die('не заполнен скрипт формы шаблона');
}
if (!$tpl_src_title = htmlCHR($this->request['tpl_src_title']))
{
$this->ajax_die('не заполнен формат названия темы');
}
$tpl_src_title = str_compact($tpl_src_title);
if (!$tpl_src_form = htmlCHR($this->request['tpl_src_form'])) {
$this->ajax_die('не заполнен скрипт формы шаблона');
}
if (!$tpl_src_title = htmlCHR($this->request['tpl_src_title'])) {
$this->ajax_die('не заполнен формат названия темы');
}
$tpl_src_title = str_compact($tpl_src_title);
if (!$tpl_src_msg = htmlCHR($this->request['tpl_src_msg']))
{
$this->ajax_die('не заполнен формат создания сообщения');
}
if (!$tpl_src_msg = htmlCHR($this->request['tpl_src_msg'])) {
$this->ajax_die('не заполнен формат создания сообщения');
}
$tpl_comment = htmlCHR($this->request['tpl_comment']);
$tpl_comment = htmlCHR($this->request['tpl_comment']);
preg_match('#\d+#', (string) $this->request['tpl_rules'], $m);
$tpl_rules_post_id = isset($m[0]) ? (int) $m[0] : 0;
preg_match('#\d+#', (string)$this->request['tpl_rules'], $m);
$tpl_rules_post_id = isset($m[0]) ? (int)$m[0] : 0;
$sql_args = array(
'tpl_name' => (string) $tpl_name,
'tpl_src_form' => (string) $tpl_src_form,
'tpl_src_title' => (string) $tpl_src_title,
'tpl_src_msg' => (string) $tpl_src_msg,
'tpl_comment' => (string) $tpl_comment,
'tpl_rules_post_id' => (int) $tpl_rules_post_id,
'tpl_last_edit_tm' => (int) TIMENOW,
'tpl_last_edit_by' => (int) $userdata['user_id'],
);
break;
$sql_args = array(
'tpl_name' => (string)$tpl_name,
'tpl_src_form' => (string)$tpl_src_form,
'tpl_src_title' => (string)$tpl_src_title,
'tpl_src_msg' => (string)$tpl_src_msg,
'tpl_comment' => (string)$tpl_comment,
'tpl_rules_post_id' => (int)$tpl_rules_post_id,
'tpl_last_edit_tm' => (int)TIMENOW,
'tpl_last_edit_by' => (int)$userdata['user_id'],
);
break;
}
// выполнение
switch ($mode)
{
// загрузка шаблона
case 'load':
$this->response['val']['tpl-name-save'] = $tpl_data['tpl_name'];
$this->response['val']['tpl-src-form'] = $tpl_data['tpl_src_form'];
$this->response['val']['tpl-src-title'] = $tpl_data['tpl_src_title'];
$this->response['val']['tpl-src-msg'] = $tpl_data['tpl_src_msg'];
$this->response['val']['tpl-comment-save'] = $tpl_data['tpl_comment'];
$this->response['val']['tpl-rules-save'] = $tpl_data['tpl_rules_post_id'];
array_deep($this->response['val'], 'html_ent_decode');
switch ($mode) {
// загрузка шаблона
case 'load':
$this->response['val']['tpl-name-save'] = $tpl_data['tpl_name'];
$this->response['val']['tpl-src-form'] = $tpl_data['tpl_src_form'];
$this->response['val']['tpl-src-title'] = $tpl_data['tpl_src_title'];
$this->response['val']['tpl-src-msg'] = $tpl_data['tpl_src_msg'];
$this->response['val']['tpl-comment-save'] = $tpl_data['tpl_comment'];
$this->response['val']['tpl-rules-save'] = $tpl_data['tpl_rules_post_id'];
array_deep($this->response['val'], 'html_ent_decode');
$this->response['val']['tpl-id-save'] = $tpl_id;
$this->response['val']['tpl-last-edit-tst'] = $tpl_data['tpl_last_edit_tm'];
$this->response['html']['tpl-name-old-save'] = $tpl_data['tpl_name'];
$this->response['html']['tpl-last-edit-time'] = bb_date($tpl_data['tpl_last_edit_tm'], 'd-M-y H:i');
$this->response['html']['tpl-last-edit-by'] = get_username(intval($tpl_data['tpl_last_edit_by']));
$this->response['val']['tpl-id-save'] = $tpl_id;
$this->response['val']['tpl-last-edit-tst'] = $tpl_data['tpl_last_edit_tm'];
$this->response['html']['tpl-name-old-save'] = $tpl_data['tpl_name'];
$this->response['html']['tpl-last-edit-time'] = bb_date($tpl_data['tpl_last_edit_tm'], 'd-M-y H:i');
$this->response['html']['tpl-last-edit-by'] = get_username(intval($tpl_data['tpl_last_edit_by']));
$this->response['tpl_rules_href'] = POST_URL . $tpl_data['tpl_rules_post_id'] .'#'. $tpl_data['tpl_rules_post_id'];
break;
$this->response['tpl_rules_href'] = POST_URL . $tpl_data['tpl_rules_post_id'] . '#' . $tpl_data['tpl_rules_post_id'];
break;
// включение / отключение шаблона в форуме
case 'assign':
if (!$tpl_id = (int) $this->request['tpl_id'])
{
$this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)');
}
if (!$forum_id = (int) $this->request['forum_id'])
{
$this->ajax_die('empty forum_id');
}
if (!forum_exists($forum_id))
{
$this->ajax_die("нет такого форума [id: $forum_id]");
}
// отключение
if ($tpl_id == -1)
{
$new_tpl_id = 0;
$this->response['msg'] = 'Шаблоны в этом форуме отключены';
}
// включение
else
{
if (!$tpl_name = DB()->fetch_row("SELECT tpl_name FROM ". BB_TOPIC_TPL ." WHERE tpl_id = $tpl_id LIMIT 1", 'tpl_name'))
{
$this->ajax_die("Шаблон [id: $tpl_id] не найден в БД");
}
$new_tpl_id = $tpl_id;
$this->response['msg'] = "Включен шаблон $tpl_name";
}
DB()->query("UPDATE ". BB_FORUMS ." SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id LIMIT 1");
break;
// включение / отключение шаблона в форуме
case 'assign':
if (!$tpl_id = (int)$this->request['tpl_id']) {
$this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)');
}
if (!$forum_id = (int)$this->request['forum_id']) {
$this->ajax_die('empty forum_id');
}
if (!forum_exists($forum_id)) {
$this->ajax_die("нет такого форума [id: $forum_id]");
}
// отключение
if ($tpl_id == -1) {
$new_tpl_id = 0;
$this->response['msg'] = 'Шаблоны в этом форуме отключены';
} // включение
else {
if (!$tpl_name = DB()->fetch_row("SELECT tpl_name FROM " . BB_TOPIC_TPL . " WHERE tpl_id = $tpl_id LIMIT 1", 'tpl_name')) {
$this->ajax_die("Шаблон [id: $tpl_id] не найден в БД");
}
$new_tpl_id = $tpl_id;
$this->response['msg'] = "Включен шаблон $tpl_name";
}
DB()->query("UPDATE " . BB_FORUMS . " SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id LIMIT 1");
break;
// сохранение изменений
case 'save':
if ($tpl_data['tpl_last_edit_tm'] > $this->request['tpl_l_ed_tst'] && $tpl_data['tpl_last_edit_by'] != $userdata['user_id'])
{
$last_edit_by_username = get_username(intval($tpl_data['tpl_last_edit_by']));
$msg = "Изменения не были сохранены!\n\n";
$msg .= 'Шаблон был отредактирован: '. html_entity_decode($last_edit_by_username) .', '. delta_time($tpl_data['tpl_last_edit_tm']) ." назад\n\n";
$this->ajax_die($msg);
}
$sql = "UPDATE ". BB_TOPIC_TPL ." SET ". DB()->build_array('UPDATE', $sql_args) ." WHERE tpl_id = $tpl_id LIMIT 1";
if (!@DB()->query($sql))
{
$sql_error = DB()->sql_error();
}
$this->response['tpl_id'] = $tpl_id;
$this->response['tpl_name'] = $tpl_name;
$this->response['html']['tpl-last-edit-time'] = bb_date(TIMENOW, 'd-M-y H:i');
$this->response['html']['tpl-last-edit-by'] = $userdata['username'];
break;
// сохранение изменений
case 'save':
if ($tpl_data['tpl_last_edit_tm'] > $this->request['tpl_l_ed_tst'] && $tpl_data['tpl_last_edit_by'] != $userdata['user_id']) {
$last_edit_by_username = get_username(intval($tpl_data['tpl_last_edit_by']));
$msg = "Изменения не были сохранены!\n\n";
$msg .= 'Шаблон был отредактирован: ' . html_entity_decode($last_edit_by_username) . ', ' . delta_time($tpl_data['tpl_last_edit_tm']) . " назад\n\n";
$this->ajax_die($msg);
}
$sql = "UPDATE " . BB_TOPIC_TPL . " SET " . DB()->build_array('UPDATE', $sql_args) . " WHERE tpl_id = $tpl_id LIMIT 1";
if (!@DB()->query($sql)) {
$sql_error = DB()->sql_error();
}
$this->response['tpl_id'] = $tpl_id;
$this->response['tpl_name'] = $tpl_name;
$this->response['html']['tpl-last-edit-time'] = bb_date(TIMENOW, 'd-M-y H:i');
$this->response['html']['tpl-last-edit-by'] = $userdata['username'];
break;
// создание нового шаблона
case 'new':
$sql = "INSERT INTO ". BB_TOPIC_TPL . DB()->build_array('INSERT', $sql_args);
if (!@DB()->query($sql))
{
$sql_error = DB()->sql_error();
}
break;
// создание нового шаблона
case 'new':
$sql = "INSERT INTO " . BB_TOPIC_TPL . DB()->build_array('INSERT', $sql_args);
if (!@DB()->query($sql)) {
$sql_error = DB()->sql_error();
}
break;
// ошибочный $mode
default:
$this->ajax_die("invalid mode: $mode");
// ошибочный $mode
default:
$this->ajax_die("invalid mode: $mode");
}
// возможный дубль названия шаблона
if ($sql_error)
{
if ($sql_error['code'] == 1062) // Duplicate entry
{
$this->ajax_die('Шаблон с таким названием уже существует, выберите другое название');
}
$this->ajax_die("db error {$sql_error['code']}: {$sql_error['message']}");
if ($sql_error) {
if ($sql_error['code'] == 1062) {
// Duplicate entry
$this->ajax_die('Шаблон с таким названием уже существует, выберите другое название');
}
$this->ajax_die("db error {$sql_error['code']}: {$sql_error['message']}");
}
// выход
$this->response['mode'] = $mode;
$this->response['timestamp'] = TIMENOW;
$this->response['mode'] = $mode;
$this->response['timestamp'] = TIMENOW;

View file

@ -1,72 +1,79 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $lang, $userdata;
$mode = (string) $this->request['mode'];
$mode = (string)$this->request['mode'];
$html = '<img src="./styles/images/good.gif">';
switch($mode)
{
case 'check_name':
$username = clean_username($this->request['username']);
switch ($mode) {
case 'check_name':
$username = clean_username($this->request['username']);
if (empty($username))
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. $lang['CHOOSE_A_NAME'] .'</span>';
}
elseif($err = validate_username($username))
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. $err .'</span>';
}
break;
if (empty($username)) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $lang['CHOOSE_A_NAME'] . '</span>';
} elseif ($err = validate_username($username)) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $err . '</span>';
}
break;
case 'check_email':
$email = (string) $this->request['email'];
case 'check_email':
$email = (string)$this->request['email'];
if (empty($email))
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. $lang['CHOOSE_E_MAIL'] .'</span>';
}
elseif($err = validate_email($email))
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. $err .'</span>';
}
break;
if (empty($email)) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $lang['CHOOSE_E_MAIL'] . '</span>';
} elseif ($err = validate_email($email)) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $err . '</span>';
}
break;
case 'check_pass':
$pass = (string) $this->request['pass'];
$pass_confirm = (string) $this->request['pass_confirm'];
if (empty($pass) || empty($pass_confirm))
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. $lang['CHOOSE_PASS'] .'</span>';
}
else
{
if ($pass != $pass_confirm)
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. $lang['CHOOSE_PASS_ERR'] .'</span>';
}
else
{
if (mb_strlen($pass, 'UTF-8') > 20)
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. sprintf($lang['CHOOSE_PASS_ERR_MAX'], 20) .'</span>';
}
elseif (mb_strlen($pass, 'UTF-8') < 5)
{
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">'. sprintf($lang['CHOOSE_PASS_ERR_MIN'], 5) .'</span>';
}
else
{
$text = (IS_GUEST) ? $lang['CHOOSE_PASS_REG_OK'] : $lang['CHOOSE_PASS_OK'];
$html = '<img src="./styles/images/good.gif"> <span class="seedmed bold">'. $text .'</span>';
}
}
}
break;
case 'check_pass':
$pass = (string)$this->request['pass'];
$pass_confirm = (string)$this->request['pass_confirm'];
if (empty($pass) || empty($pass_confirm)) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $lang['CHOOSE_PASS'] . '</span>';
} else {
if ($pass != $pass_confirm) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $lang['CHOOSE_PASS_ERR'] . '</span>';
} else {
if (mb_strlen($pass, 'UTF-8') > 20) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . sprintf($lang['CHOOSE_PASS_ERR_MAX'], 20) . '</span>';
} elseif (mb_strlen($pass, 'UTF-8') < 5) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . sprintf($lang['CHOOSE_PASS_ERR_MIN'], 5) . '</span>';
} else {
$text = (IS_GUEST) ? $lang['CHOOSE_PASS_REG_OK'] : $lang['CHOOSE_PASS_OK'];
$html = '<img src="./styles/images/good.gif"> <span class="seedmed bold">' . $text . '</span>';
}
}
}
break;
}
$this->response['html'] = $html;
$this->response['mode'] = $mode;
$this->response['mode'] = $mode;

View file

@ -1,15 +1,39 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $user, $lang;
$post_id = (int) @$this->request['post_id'];
$topic_id = (int) @$this->request['topic_id'];
$post_id = (int)@$this->request['post_id'];
$topic_id = (int)@$this->request['topic_id'];
if (!$post_id)
{
$post_id = DB()->fetch_row("SELECT topic_first_post_id FROM ". BB_TOPICS ." WHERE topic_id = $topic_id", 'topic_first_post_id');
if (!$post_id) {
$post_id = DB()->fetch_row("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id", 'topic_first_post_id');
}
$sql = "
@ -17,37 +41,31 @@ $sql = "
p.*,
h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text,
f.auth_read
FROM ". BB_POSTS ." p
INNER JOIN ". BB_POSTS_TEXT ." pt ON(pt.post_id = p.post_id)
LEFT JOIN ". BB_POSTS_HTML ." h ON(h.post_id = pt.post_id)
INNER JOIN ". BB_FORUMS ." f ON(f.forum_id = p.forum_id)
FROM " . BB_POSTS . " p
INNER JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id)
LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = pt.post_id)
INNER JOIN " . BB_FORUMS . " f ON(f.forum_id = p.forum_id)
WHERE
p.post_id = $post_id
LIMIT 1
";
if (!$post_data = DB()->fetch_row($sql))
{
$this->ajax_die($lang['TOPIC_POST_NOT_EXIST']);
if (!$post_data = DB()->fetch_row($sql)) {
$this->ajax_die($lang['TOPIC_POST_NOT_EXIST']);
}
// Auth check
if ($post_data['auth_read'] == AUTH_REG)
{
if (IS_GUEST)
{
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
}
elseif ($post_data['auth_read'] != AUTH_ALL)
{
$is_auth = auth(AUTH_READ, $post_data['forum_id'], $user->data, $post_data);
if (!$is_auth['auth_read'])
{
$this->ajax_die($lang['TOPIC_POST_NOT_EXIST']);
}
if ($post_data['auth_read'] == AUTH_REG) {
if (IS_GUEST) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
} elseif ($post_data['auth_read'] != AUTH_ALL) {
$is_auth = auth(AUTH_READ, $post_data['forum_id'], $user->data, $post_data);
if (!$is_auth['auth_read']) {
$this->ajax_die($lang['TOPIC_POST_NOT_EXIST']);
}
}
$this->response['post_id'] = $post_id;
$this->response['topic_id'] = $topic_id;
$this->response['post_html'] = get_parsed_post($post_data);
$this->response['post_id'] = $post_id;
$this->response['topic_id'] = $topic_id;
$this->response['post_html'] = get_parsed_post($post_data);

View file

@ -1,186 +1,190 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $lang;
if (!isset($this->request['attach_id']))
{
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
$attach_id = (int) $this->request['attach_id'];
$attach_id = (int)$this->request['attach_id'];
global $bnc_error;
$bnc_error = 0;
$torrent = DB()->fetch_row("SELECT at.attach_id, at.physical_filename FROM ". BB_ATTACHMENTS_DESC ." at WHERE at.attach_id = $attach_id LIMIT 1");
if (!$torrent) $this->ajax_die($lang['EMPTY_ATTACH_ID']);
$filename = get_attachments_dir() .'/'. $torrent['physical_filename'];
$torrent = DB()->fetch_row("SELECT at.attach_id, at.physical_filename FROM " . BB_ATTACHMENTS_DESC . " at WHERE at.attach_id = $attach_id LIMIT 1");
if (!$torrent) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
$filename = get_attachments_dir() . '/' . $torrent['physical_filename'];
if (($file_contents = @file_get_contents($filename)) === false)
{
if (IS_AM)
{
$this->ajax_die($lang['ERROR_NO_ATTACHMENT'] ."\n\n". htmlCHR($filename));
}
else
{
$this->ajax_die($lang['ERROR_NO_ATTACHMENT']);
}
if (($file_contents = @file_get_contents($filename)) === false) {
if (IS_AM) {
$this->ajax_die($lang['ERROR_NO_ATTACHMENT'] . "\n\n" . htmlCHR($filename));
} else {
$this->ajax_die($lang['ERROR_NO_ATTACHMENT']);
}
}
// Построение списка
$tor_filelist = build_tor_filelist($file_contents);
function build_tor_filelist ($file_contents)
function build_tor_filelist($file_contents)
{
global $lang;
global $lang;
if (!$tor = bdecode($file_contents))
{
return $lang['TORFILE_INVALID'];
}
if (!$tor = bdecode($file_contents)) {
return $lang['TORFILE_INVALID'];
}
$torrent = new torrent($tor);
$torrent = new torrent($tor);
return $torrent->get_filelist();
return $torrent->get_filelist();
}
class torrent
{
public $tor_decoded = array();
public $files_ary = array('/' => '');
public $multiple = null;
public $root_dir = '';
public $files_html = '';
public $tor_decoded = array();
public $files_ary = array('/' => '');
public $multiple = null;
public $root_dir = '';
public $files_html = '';
public function __construct ($decoded_file_contents)
{
$this->tor_decoded = $decoded_file_contents;
}
public function __construct($decoded_file_contents)
{
$this->tor_decoded = $decoded_file_contents;
}
public function get_filelist ()
{
$this->build_filelist_array();
public function get_filelist()
{
$this->build_filelist_array();
if ($this->multiple)
{
if ($this->files_ary['/'] !== '')
{
$this->files_ary = array_merge($this->files_ary, $this->files_ary['/']);
unset($this->files_ary['/']);
}
$filelist = $this->build_filelist_html();
return "<div class=\"tor-root-dir\">{$this->root_dir}</div>$filelist";
}
else
{
return join('', $this->files_ary['/']);
}
}
if ($this->multiple) {
if ($this->files_ary['/'] !== '') {
$this->files_ary = array_merge($this->files_ary, $this->files_ary['/']);
unset($this->files_ary['/']);
}
$filelist = $this->build_filelist_html();
return "<div class=\"tor-root-dir\">{$this->root_dir}</div>$filelist";
} else {
return join('', $this->files_ary['/']);
}
}
public function build_filelist_array ()
{
$info = $this->tor_decoded['info'];
public function build_filelist_array()
{
$info = $this->tor_decoded['info'];
if (isset($info['name.utf-8']))
{
$info['name'] =& $info['name.utf-8'];
}
if (isset($info['name.utf-8'])) {
$info['name'] =& $info['name.utf-8'];
}
if (isset($info['files']) && is_array($info['files']))
{
$this->root_dir = isset($info['name']) ? '../'. clean_tor_dirname($info['name']) : '...';
$this->multiple = true;
if (isset($info['files']) && is_array($info['files'])) {
$this->root_dir = isset($info['name']) ? '../' . clean_tor_dirname($info['name']) : '...';
$this->multiple = true;
foreach ($info['files'] as $f)
{
if (isset($f['path.utf-8']))
{
$f['path'] =& $f['path.utf-8'];
}
if (!isset($f['path']) || !is_array($f['path']))
{
continue;
}
array_deep($f['path'], 'clean_tor_dirname');
foreach ($info['files'] as $f) {
if (isset($f['path.utf-8'])) {
$f['path'] =& $f['path.utf-8'];
}
if (!isset($f['path']) || !is_array($f['path'])) {
continue;
}
array_deep($f['path'], 'clean_tor_dirname');
$length = isset($f['length']) ? (float) $f['length'] : 0;
$subdir_count = count($f['path']) - 1;
$length = isset($f['length']) ? (float)$f['length'] : 0;
$subdir_count = count($f['path']) - 1;
if ($subdir_count > 0)
{
$name = array_pop($f['path']);
$cur_files_ary =& $this->files_ary;
if ($subdir_count > 0) {
$name = array_pop($f['path']);
$cur_files_ary =& $this->files_ary;
for ($i=0,$j=1; $i < $subdir_count; $i++,$j++)
{
$subdir = $f['path'][$i];
for ($i = 0, $j = 1; $i < $subdir_count; $i++, $j++) {
$subdir = $f['path'][$i];
if (!isset($cur_files_ary[$subdir]))
{
$cur_files_ary[$subdir] = array();
}
$cur_files_ary =& $cur_files_ary[$subdir];
if (!isset($cur_files_ary[$subdir])) {
$cur_files_ary[$subdir] = array();
}
$cur_files_ary =& $cur_files_ary[$subdir];
if ($j == $subdir_count)
{
if (is_string($cur_files_ary))
{
$GLOBALS['bnc_error'] = 1;
break(1);
}
$cur_files_ary[] = $this->build_file_item($name, $length);
}
}
@natsort($cur_files_ary);
}
else
{
$name = $f['path'][0];
$this->files_ary['/'][] = $this->build_file_item($name, $length);
natsort($this->files_ary['/']);
}
}
}
else
{
$this->multiple = false;
$name = isset($info['name']) ? clean_tor_dirname($info['name']) : '';
$length = isset($info['length']) ? (float) $info['length'] : 0;
if ($j == $subdir_count) {
if (is_string($cur_files_ary)) {
$GLOBALS['bnc_error'] = 1;
break(1);
}
$cur_files_ary[] = $this->build_file_item($name, $length);
}
}
@natsort($cur_files_ary);
} else {
$name = $f['path'][0];
$this->files_ary['/'][] = $this->build_file_item($name, $length);
natsort($this->files_ary['/']);
}
}
} else {
$this->multiple = false;
$name = isset($info['name']) ? clean_tor_dirname($info['name']) : '';
$length = isset($info['length']) ? (float)$info['length'] : 0;
$this->files_ary['/'][] = $this->build_file_item($name, $length);
natsort($this->files_ary['/']);
}
}
$this->files_ary['/'][] = $this->build_file_item($name, $length);
natsort($this->files_ary['/']);
}
}
public function build_file_item ($name, $length)
{
global $bb_cfg, $images, $lang;
public function build_file_item($name, $length)
{
global $bb_cfg, $images, $lang;
$magnet_name = $magnet_ext = '';
$magnet_name = $magnet_ext = '';
if ($bb_cfg['magnet_links_enabled'])
{
$magnet_name = '<a title="'.$lang['DC_MAGNET'].'" href="dchub:magnet:?kt='.$name.'&xl='.$length.'"><img src="'. $images['icon_dc_magnet'] .'" width="10" height="10" border="0" /></a>';
$magnet_ext = '<a title="'.$lang['DC_MAGNET_EXT'].'" href="dchub:magnet:?kt=.'.substr(strrchr($name, '.'), 1).'&xl='.$length.'"><img src="'. $images['icon_dc_magnet_ext'] .'" width="10" height="10" border="0" /></a>';
}
if ($bb_cfg['magnet_links_enabled']) {
$magnet_name = '<a title="' . $lang['DC_MAGNET'] . '" href="dchub:magnet:?kt=' . $name . '&xl=' . $length . '"><img src="' . $images['icon_dc_magnet'] . '" width="10" height="10" border="0" /></a>';
$magnet_ext = '<a title="' . $lang['DC_MAGNET_EXT'] . '" href="dchub:magnet:?kt=.' . substr(strrchr($name, '.'), 1) . '&xl=' . $length . '"><img src="' . $images['icon_dc_magnet_ext'] . '" width="10" height="10" border="0" /></a>';
}
return "$name <i>$length</i> $magnet_name $magnet_ext";
}
return "$name <i>$length</i> $magnet_name $magnet_ext";
}
public function build_filelist_html ()
{
global $html;
return $html->array2html($this->files_ary);
}
public function build_filelist_html()
{
global $html;
return $html->array2html($this->files_ary);
}
}
function clean_tor_dirname ($dirname)
function clean_tor_dirname($dirname)
{
return str_replace(array('[', ']', '<', '>', "'"), array('&#91;', '&#93;', '&lt;', '&gt;', '&#039;'), $dirname);
return str_replace(array('[', ']', '<', '>', "'"), array('&#91;', '&#93;', '&lt;', '&gt;', '&#039;'), $dirname);
}
if ($bnc_error) $tor_filelist = '<b style="color: #993300;">'.$lang['ERROR_BUILD'].'</b><br /><br />'.$tor_filelist;
if ($bnc_error) {
$tor_filelist = '<b style="color: #993300;">' . $lang['ERROR_BUILD'] . '</b><br /><br />' . $tor_filelist;
}
$this->response['html'] = $tor_filelist;

View file

@ -1,82 +1,97 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_FORUM')) die("Hacking attempt");
if (!defined('IN_FORUM')) {
die("Hacking attempt");
}
require(ATTACH_DIR .'includes/functions_includes.php');
require(ATTACH_DIR .'includes/functions_attach.php');
require(ATTACH_DIR .'includes/functions_delete.php');
require(ATTACH_DIR .'includes/functions_thumbs.php');
require(ATTACH_DIR .'includes/functions_filetypes.php');
require(ATTACH_DIR . 'includes/functions_includes.php');
require(ATTACH_DIR . 'includes/functions_attach.php');
require(ATTACH_DIR . 'includes/functions_delete.php');
require(ATTACH_DIR . 'includes/functions_thumbs.php');
require(ATTACH_DIR . 'includes/functions_filetypes.php');
if (defined('ATTACH_INSTALL'))
{
return;
if (defined('ATTACH_INSTALL')) {
return;
}
/**
* wrapper function for determining the correct language directory
*/
* wrapper function for determining the correct language directory
*/
function attach_mod_get_lang($language_file)
{
global $attach_config, $bb_cfg;
global $attach_config, $bb_cfg;
$language = $bb_cfg['default_lang'];
if (!file_exists(LANG_ROOT_DIR ."$language/$language_file.php"))
{
$language = $attach_config['board_lang'];
$language = $bb_cfg['default_lang'];
if (!file_exists(LANG_ROOT_DIR . "$language/$language_file.php")) {
$language = $attach_config['board_lang'];
if (!file_exists(LANG_ROOT_DIR ."$language/$language_file.php"))
{
bb_die('Attachment mod language file does not exist: language/' . $language . '/' . $language_file . '.php');
}
else
{
return $language;
}
}
else
{
return $language;
}
if (!file_exists(LANG_ROOT_DIR . "$language/$language_file.php")) {
bb_die('Attachment mod language file does not exist: language/' . $language . '/' . $language_file . '.php');
} else {
return $language;
}
} else {
return $language;
}
}
/**
* Get attachment mod configuration
*/
* Get attachment mod configuration
*/
function get_config()
{
global $bb_cfg;
global $bb_cfg;
$attach_config = array();
$attach_config = array();
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachment information');
}
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']);
}
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']);
// 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;
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);
if (!$attach_config = CACHE('bb_cache')->get('attach_config')) {
$attach_config = get_config();
CACHE('bb_cache')->set('attach_config', $attach_config, 86400);
}
include(ATTACH_DIR .'displaying.php');
include(ATTACH_DIR .'posting_attachments.php');
include(ATTACH_DIR . 'displaying.php');
include(ATTACH_DIR . 'posting_attachments.php');
$upload_dir = $attach_config['upload_dir'];
$upload_dir = $attach_config['upload_dir'];

View file

@ -1,6 +1,31 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_FORUM')) die("Hacking attempt");
if (!defined('IN_FORUM')) {
die("Hacking attempt");
}
$allowed_extensions = array();
$display_categories = array();
@ -9,338 +34,289 @@ $upload_icons = array();
$attachments = array();
/**
* Create needed arrays for Extension Assignments
*/
* Create needed arrays for Extension Assignments
*/
function init_complete_extensions_data()
{
global $allowed_extensions, $display_categories, $download_modes, $upload_icons;
global $allowed_extensions, $display_categories, $download_modes, $upload_icons;
if (!$extension_informations = get_extension_informations())
{
$extension_informations = $GLOBALS['datastore']->update('attach_extensions'); //get_extension_informations()
$extension_informations = get_extension_informations();
}
$allowed_extensions = array();
if (!$extension_informations = get_extension_informations()) {
$extension_informations = $GLOBALS['datastore']->update('attach_extensions'); //get_extension_informations()
$extension_informations = get_extension_informations();
}
$allowed_extensions = array();
for ($i = 0, $size = sizeof($extension_informations); $i < $size; $i++)
{
$extension = strtolower(trim($extension_informations[$i]['extension']));
$allowed_extensions[] = $extension;
$display_categories[$extension] = intval($extension_informations[$i]['cat_id']);
$download_modes[$extension] = intval($extension_informations[$i]['download_mode']);
$upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']);
}
for ($i = 0, $size = sizeof($extension_informations); $i < $size; $i++) {
$extension = strtolower(trim($extension_informations[$i]['extension']));
$allowed_extensions[] = $extension;
$display_categories[$extension] = intval($extension_informations[$i]['cat_id']);
$download_modes[$extension] = intval($extension_informations[$i]['download_mode']);
$upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']);
}
}
/**
* Writing Data into plain Template Vars
*/
* Writing Data into plain Template Vars
*/
function init_display_template($template_var, $replacement, $filename = 'viewtopic_attach.tpl')
{
global $template;
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)
// 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");
}
// 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];
$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");
}
$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;
}
$template->uncompiled_code[$template_var] = $str;
}
$complete_filename = $filename;
if (substr($complete_filename, 0, 1) != '/')
{
$complete_filename = $template->root . '/' . $complete_filename;
}
$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");
}
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');
}
$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]);
// 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
*/
* Display Attachments in Posts
*/
function display_post_attachments($post_id, $switch_attachment)
{
global $attach_config, $is_auth;
global $attach_config, $is_auth;
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']))
{
return;
}
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod'])) {
return;
}
if ($is_auth['auth_download'] && $is_auth['auth_view'])
{
display_attachments($post_id);
}
if ($is_auth['auth_download'] && $is_auth['auth_view']) {
display_attachments($post_id);
}
}
/**
* Initializes some templating variables for displaying Attachments in Posts
*/
* Initializes some templating variables for displaying Attachments in Posts
*/
function init_display_post_attachments($switch_attachment)
{
global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data;
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 (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;
}
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();
$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'];
}
}
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;
}
if (sizeof($post_id_array) == 0) {
return;
}
$rows = get_attachments_from_post($post_id_array);
$num_rows = sizeof($rows);
$rows = get_attachments_from_post($post_id_array);
$num_rows = sizeof($rows);
if ($num_rows == 0)
{
return;
}
if ($num_rows == 0) {
return;
}
@reset($attachments);
@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
}
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}');
init_display_template('body', '{postrow.ATTACHMENTS}');
init_complete_extensions_data();
init_complete_extensions_data();
}
/**
* END ATTACHMENT DISPLAY IN POSTS
*/
* END ATTACHMENT DISPLAY IN POSTS
*/
/**
* Assign Variables and Definitions based on the fetched Attachments - internal
* used by all displaying functions, the Data was collected before, it's only dependend on the template used. :)
* before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...)
*/
* Assign Variables and Definitions based on the fetched Attachments - internal
* used by all displaying functions, the Data was collected before, it's only dependend on the template used. :)
* before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...)
*/
function display_attachments($post_id)
{
global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config;
global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config;
$num_attachments = @sizeof($attachments['_' . $post_id]);
$num_attachments = @sizeof($attachments['_' . $post_id]);
if ($num_attachments == 0)
{
return;
}
if ($num_attachments == 0) {
return;
}
$template->assign_block_vars('postrow.attach', array());
$template->assign_block_vars('postrow.attach', array());
for ($i = 0; $i < $num_attachments; $i++)
{
// Some basic things...
$filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']);
$thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']);
for ($i = 0; $i < $num_attachments; $i++) {
// Some basic things...
$filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']);
$thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']);
$upload_image = '';
$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" />';
}
if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']])) {
$upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
} elseif (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']);
$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);
$display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']);
$comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']);
$comment = str_replace("\n", '<br />', $comment);
$denied = false;
$denied = false;
// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions))
{
$denied = true;
// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) {
$denied = true;
$template->assign_block_vars('postrow.attach.denyrow', array(
'L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension']))
);
}
$template->assign_block_vars('postrow.attach.denyrow', array(
'L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension']))
);
}
if (!$denied || IS_ADMIN)
{
// define category
$image = FALSE;
$thumbnail = FALSE;
$link = FALSE;
if (!$denied || IS_ADMIN) {
// define category
$image = false;
$thumbnail = false;
$link = false;
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined']))
{
if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0)
{
list($width, $height) = image_getdimension($filename);
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) {
if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) {
list($width, $height) = image_getdimension($filename);
if ($width == 0 && $height == 0)
{
$image = TRUE;
}
else
{
if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height']))
{
$image = TRUE;
}
}
}
else
{
$image = TRUE;
}
}
if ($width == 0 && $height == 0) {
$image = true;
} else {
if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) {
$image = true;
}
}
} else {
$image = true;
}
}
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1)
{
$thumbnail = TRUE;
$image = FALSE;
}
if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) {
$thumbnail = true;
$image = false;
}
if (!$image && !$thumbnail)
{
$link = TRUE;
}
if (!$image && !$thumbnail) {
$link = true;
}
if ($image)
{
// Images
if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
$img_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'];
$download_link = TRUE;
}
else
{
$img_source = $filename;
$download_link = FALSE;
}
if ($image) {
// Images
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
$img_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'];
$download_link = true;
} else {
$img_source = $filename;
$download_link = false;
}
$template->assign_block_vars('postrow.attach.cat_images', array(
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => $img_source,
'FILESIZE' => $filesize,
'COMMENT' => $comment,
));
$template->assign_block_vars('postrow.attach.cat_images', array(
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => $img_source,
'FILESIZE' => $filesize,
'COMMENT' => $comment,
));
// Directly Viewed Image ... update the download count
if (!$download_link)
{
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . '
// Directly Viewed Image ... update the download count
if (!$download_link) {
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . '
SET download_count = download_count + 1
WHERE attach_id = ' . (int) $attachments['_' . $post_id][$i]['attach_id'];
WHERE attach_id = ' . (int)$attachments['_' . $post_id][$i]['attach_id'];
if (!(DB()->sql_query($sql)))
{
bb_die('Could not update attachment download count');
}
}
}
if (!(DB()->sql_query($sql))) {
bb_die('Could not update attachment download count');
}
}
}
if ($thumbnail)
{
// Images, but display Thumbnail
if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
$thumb_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1';
}
else
{
$thumb_source = $thumbnail_filename;
}
if ($thumbnail) {
// Images, but display Thumbnail
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
$thumb_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1';
} else {
$thumb_source = $thumbnail_filename;
}
$template->assign_block_vars('postrow.attach.cat_thumb_images', array(
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'],
'IMG_THUMB_SRC' => $thumb_source,
'FILESIZE' => $filesize,
'COMMENT' => $comment,
));
}
$template->assign_block_vars('postrow.attach.cat_thumb_images', array(
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'],
'IMG_THUMB_SRC' => $thumb_source,
'FILESIZE' => $filesize,
'COMMENT' => $comment,
));
}
// bt
if ($link && ($attachments['_'. $post_id][$i]['extension'] === TORRENT_EXT))
{
include(ATTACH_DIR .'displaying_torrent.php');
}
else if ($link)
{
$target_blank = ( (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT) ) ? 'target="_blank"' : '';
// bt
if ($link && ($attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT)) {
include(ATTACH_DIR . 'displaying_torrent.php');
} elseif ($link) {
$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']),
));
}
}
}
}
// 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']),
));
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,191 +1,177 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* All Attachment Functions only needed in Admin
*/
* All Attachment Functions only needed in Admin
*/
/**
* Set/Change Quotas
*/
* Set/Change Quotas
*/
function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
{
$id = (int) $id;
$quota_type = (int) $quota_type;
$quota_limit_id = (int) $quota_limit_id;
$id = (int)$id;
$quota_type = (int)$quota_type;
$quota_limit_id = (int)$quota_limit_id;
if ($mode == 'user')
{
if (!$quota_limit_id)
{
$sql = 'DELETE FROM ' . BB_QUOTA . "
if ($mode == 'user') {
if (!$quota_limit_id) {
$sql = 'DELETE FROM ' . BB_QUOTA . "
WHERE user_id = $id
AND quota_type = $quota_type";
}
else
{
// Check if user is already entered
$sql = 'SELECT user_id
} else {
// Check if user is already entered
$sql = 'SELECT user_id
FROM ' . BB_QUOTA . "
WHERE user_id = $id
AND quota_type = $quota_type";
if( !($result = DB()->sql_query($sql)) )
{
bb_die('Could not get entry #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get entry #1');
}
if (DB()->num_rows($result) == 0)
{
$sql_ary = array(
'user_id' => (int) $id,
'group_id' => 0,
'quota_type' => (int) $quota_type,
'quota_limit_id'=> (int) $quota_limit_id
);
if (DB()->num_rows($result) == 0) {
$sql_ary = array(
'user_id' => (int)$id,
'group_id' => 0,
'quota_type' => (int)$quota_type,
'quota_limit_id' => (int)$quota_limit_id
);
$sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
}
else
{
$sql = 'UPDATE ' . BB_QUOTA . "
$sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
} else {
$sql = 'UPDATE ' . BB_QUOTA . "
SET quota_limit_id = $quota_limit_id
WHERE user_id = $id
AND quota_type = $quota_type";
}
DB()->sql_freeresult($result);
}
}
DB()->sql_freeresult($result);
}
if (!($result = DB()->sql_query($sql)))
{
bb_die('Unable to update quota settings');
}
}
else if ($mode == 'group')
{
if (!$quota_limit_id)
{
$sql = 'DELETE FROM ' . BB_QUOTA . "
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to update quota settings');
}
} elseif ($mode == 'group') {
if (!$quota_limit_id) {
$sql = 'DELETE FROM ' . BB_QUOTA . "
WHERE group_id = $id
AND quota_type = $quota_type";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Unable to delete quota settings');
}
}
else
{
// Check if user is already entered
$sql = 'SELECT group_id
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to delete quota settings');
}
} else {
// Check if user is already entered
$sql = 'SELECT group_id
FROM ' . BB_QUOTA . "
WHERE group_id = $id
AND quota_type = $quota_type";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not get entry #2');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get entry #2');
}
if (DB()->num_rows($result) == 0)
{
$sql = 'INSERT INTO ' . BB_QUOTA . " (user_id, group_id, quota_type, quota_limit_id)
if (DB()->num_rows($result) == 0) {
$sql = 'INSERT INTO ' . BB_QUOTA . " (user_id, group_id, quota_type, quota_limit_id)
VALUES (0, $id, $quota_type, $quota_limit_id)";
}
else
{
$sql = 'UPDATE ' . BB_QUOTA . " SET quota_limit_id = $quota_limit_id
} else {
$sql = 'UPDATE ' . BB_QUOTA . " SET quota_limit_id = $quota_limit_id
WHERE group_id = $id AND quota_type = $quota_type";
}
}
if (!DB()->sql_query($sql))
{
bb_die('Unable to update quota settings');
}
}
}
if (!DB()->sql_query($sql)) {
bb_die('Unable to update quota settings');
}
}
}
}
/**
* sort multi-dimensional Array
*/
function sort_multi_array ($sort_array, $key, $sort_order, $pre_string_sort = 0)
* sort multi-dimensional Array
*/
function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
{
$last_element = sizeof($sort_array) - 1;
$last_element = sizeof($sort_array) - 1;
if (!$pre_string_sort)
{
$string_sort = (!is_numeric(@$sort_array[$last_element-1][$key]) ) ? true : false;
}
else
{
$string_sort = $pre_string_sort;
}
if (!$pre_string_sort) {
$string_sort = (!is_numeric(@$sort_array[$last_element - 1][$key])) ? true : false;
} else {
$string_sort = $pre_string_sort;
}
for ($i = 0; $i < $last_element; $i++)
{
$num_iterations = $last_element - $i;
for ($i = 0; $i < $last_element; $i++) {
$num_iterations = $last_element - $i;
for ($j = 0; $j < $num_iterations; $j++)
{
$next = 0;
for ($j = 0; $j < $num_iterations; $j++) {
$next = 0;
// do checks based on key
$switch = false;
if (!$string_sort)
{
if (($sort_order == 'DESC' && intval(@$sort_array[$j][$key]) < intval(@$sort_array[$j + 1][$key])) || ($sort_order == 'ASC' && intval(@$sort_array[$j][$key]) > intval(@$sort_array[$j + 1][$key])))
{
$switch = true;
}
}
else
{
if (($sort_order == 'DESC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) < 0) || ($sort_order == 'ASC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) > 0))
{
$switch = true;
}
}
// do checks based on key
$switch = false;
if (!$string_sort) {
if (($sort_order == 'DESC' && intval(@$sort_array[$j][$key]) < intval(@$sort_array[$j + 1][$key])) || ($sort_order == 'ASC' && intval(@$sort_array[$j][$key]) > intval(@$sort_array[$j + 1][$key]))) {
$switch = true;
}
} else {
if (($sort_order == 'DESC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) < 0) || ($sort_order == 'ASC' && strcasecmp(@$sort_array[$j][$key], @$sort_array[$j + 1][$key]) > 0)) {
$switch = true;
}
}
if ($switch)
{
$temp = $sort_array[$j];
$sort_array[$j] = $sort_array[$j + 1];
$sort_array[$j + 1] = $temp;
}
}
}
if ($switch) {
$temp = $sort_array[$j];
$sort_array[$j] = $sort_array[$j + 1];
$sort_array[$j + 1] = $temp;
}
}
}
return $sort_array;
return $sort_array;
}
/**
* Returns the filesize of the upload directory in human readable format
*/
* Returns the filesize of the upload directory in human readable format
*/
function get_formatted_dirsize()
{
global $attach_config, $upload_dir, $lang;
global $attach_config, $upload_dir, $lang;
$upload_dir_size = 0;
$upload_dir_size = 0;
if ($dirname = @opendir($upload_dir))
{
while ($file = @readdir($dirname))
{
if ($file != 'index.php' && $file != '.htaccess' && !is_dir($upload_dir . '/' . $file) && !is_link($upload_dir . '/' . $file))
{
$upload_dir_size += @filesize($upload_dir . '/' . $file);
}
}
@closedir($dirname);
}
else
{
$upload_dir_size = $lang['NOT_AVAILABLE'];
return $upload_dir_size;
}
if ($dirname = @opendir($upload_dir)) {
while ($file = @readdir($dirname)) {
if ($file != 'index.php' && $file != '.htaccess' && !is_dir($upload_dir . '/' . $file) && !is_link($upload_dir . '/' . $file)) {
$upload_dir_size += @filesize($upload_dir . '/' . $file);
}
}
@closedir($dirname);
} else {
$upload_dir_size = $lang['NOT_AVAILABLE'];
return $upload_dir_size;
}
return humn_size($upload_dir_size);
return humn_size($upload_dir_size);
}
/*
@ -193,161 +179,136 @@ function get_formatted_dirsize()
*/
function search_attachments($order_by, &$total_rows)
{
global $lang;
global $lang;
$where_sql = array();
$where_sql = array();
// Get submitted Vars
$search_vars = array('search_keyword_fname', 'search_keyword_comment', 'search_author', 'search_size_smaller', 'search_size_greater', 'search_count_smaller', 'search_count_greater', 'search_days_greater', 'search_forum', 'search_cat');
// Get submitted Vars
$search_vars = array('search_keyword_fname', 'search_keyword_comment', 'search_author', 'search_size_smaller', 'search_size_greater', 'search_count_smaller', 'search_count_greater', 'search_days_greater', 'search_forum', 'search_cat');
for ($i = 0; $i < sizeof($search_vars); $i++)
{
$$search_vars[$i] = get_var($search_vars[$i], '');
}
for ($i = 0; $i < sizeof($search_vars); $i++) {
$$search_vars[$i] = get_var($search_vars[$i], '');
}
// Author name search
if ($search_author != '')
{
// Bring in line with 2.0.x expected username
$search_author = addslashes(html_entity_decode($search_author));
$search_author = stripslashes(clean_username($search_author));
// Author name search
if ($search_author != '') {
// Bring in line with 2.0.x expected username
$search_author = addslashes(html_entity_decode($search_author));
$search_author = stripslashes(clean_username($search_author));
// Prepare for directly going into sql query
$search_author = str_replace('*', '%', attach_mod_sql_escape($search_author));
// Prepare for directly going into sql query
$search_author = str_replace('*', '%', attach_mod_sql_escape($search_author));
// We need the post_id's, because we want to query the Attachment Table
$sql = 'SELECT user_id FROM ' . BB_USERS . " WHERE username LIKE '$search_author'";
// We need the post_id's, because we want to query the Attachment Table
$sql = 'SELECT user_id FROM ' . BB_USERS . " WHERE username LIKE '$search_author'";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not obtain list of matching users (searching for: ' . $search_author . ')');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain list of matching users (searching for: ' . $search_author . ')');
}
$matching_userids = '';
if ( $row = DB()->sql_fetchrow($result) )
{
do
{
$matching_userids .= (($matching_userids != '') ? ', ' : '') . intval($row['user_id']);
}
while ($row = DB()->sql_fetchrow($result));
$matching_userids = '';
if ($row = DB()->sql_fetchrow($result)) {
do {
$matching_userids .= (($matching_userids != '') ? ', ' : '') . intval($row['user_id']);
} while ($row = DB()->sql_fetchrow($result));
DB()->sql_freeresult($result);
}
else
{
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
}
DB()->sql_freeresult($result);
} else {
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
}
$where_sql[] = ' (t.user_id_1 IN (' . $matching_userids . ')) ';
}
$where_sql[] = ' (t.user_id_1 IN (' . $matching_userids . ')) ';
}
// Search Keyword
if ($search_keyword_fname != '')
{
$match_word = str_replace('*', '%', $search_keyword_fname);
$where_sql[] = " (a.real_filename LIKE '" . attach_mod_sql_escape($match_word) . "') ";
}
// Search Keyword
if ($search_keyword_fname != '') {
$match_word = str_replace('*', '%', $search_keyword_fname);
$where_sql[] = " (a.real_filename LIKE '" . attach_mod_sql_escape($match_word) . "') ";
}
if ($search_keyword_comment != '')
{
$match_word = str_replace('*', '%', $search_keyword_comment);
$where_sql[] = " (a.comment LIKE '" . attach_mod_sql_escape($match_word) . "') ";
}
if ($search_keyword_comment != '') {
$match_word = str_replace('*', '%', $search_keyword_comment);
$where_sql[] = " (a.comment LIKE '" . attach_mod_sql_escape($match_word) . "') ";
}
// Search Download Count
if ($search_count_smaller != '' || $search_count_greater != '')
{
if ($search_count_smaller != '')
{
$where_sql[] = ' (a.download_count < ' . (int) $search_count_smaller . ') ';
}
else if ($search_count_greater != '')
{
$where_sql[] = ' (a.download_count > ' . (int) $search_count_greater . ') ';
}
}
// Search Download Count
if ($search_count_smaller != '' || $search_count_greater != '') {
if ($search_count_smaller != '') {
$where_sql[] = ' (a.download_count < ' . (int)$search_count_smaller . ') ';
} elseif ($search_count_greater != '') {
$where_sql[] = ' (a.download_count > ' . (int)$search_count_greater . ') ';
}
}
// Search Filesize
if ($search_size_smaller != '' || $search_size_greater != '')
{
if ($search_size_smaller != '')
{
$where_sql[] = ' (a.filesize < ' . (int) $search_size_smaller . ') ';
}
else if ($search_size_greater != '')
{
$where_sql[] = ' (a.filesize > ' . (int) $search_size_greater . ') ';
}
}
// Search Filesize
if ($search_size_smaller != '' || $search_size_greater != '') {
if ($search_size_smaller != '') {
$where_sql[] = ' (a.filesize < ' . (int)$search_size_smaller . ') ';
} elseif ($search_size_greater != '') {
$where_sql[] = ' (a.filesize > ' . (int)$search_size_greater . ') ';
}
}
// Search Attachment Time
if ($search_days_greater != '')
{
$where_sql[] = ' (a.filetime < ' . ( TIMENOW - ((int) $search_days_greater * 86400)) . ') ';
}
// Search Attachment Time
if ($search_days_greater != '') {
$where_sql[] = ' (a.filetime < ' . (TIMENOW - ((int)$search_days_greater * 86400)) . ') ';
}
// Search Forum
if ($search_forum)
{
$where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') ';
}
// Search Forum
if ($search_forum) {
$where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') ';
}
// Search Cat... nope... sorry :(
// Search Cat... nope... sorry :(
$sql = 'SELECT a.*, t.post_id, p.post_time, p.topic_id
$sql = 'SELECT a.*, t.post_id, p.post_time, p.topic_id
FROM ' . BB_ATTACHMENTS . ' t, ' . BB_ATTACHMENTS_DESC . ' a, ' . BB_POSTS . ' p WHERE ';
if (sizeof($where_sql) > 0)
{
$sql .= implode('AND', $where_sql) . ' AND ';
}
if (sizeof($where_sql) > 0) {
$sql .= implode('AND', $where_sql) . ' AND ';
}
$sql .= 't.post_id = p.post_id AND a.attach_id = t.attach_id ';
$sql .= 't.post_id = p.post_id AND a.attach_id = t.attach_id ';
$total_rows_sql = $sql;
$total_rows_sql = $sql;
$sql .= $order_by;
$sql .= $order_by;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attachments #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #1');
}
$attachments = DB()->sql_fetchrowset($result);
$num_attach = DB()->num_rows($result);
DB()->sql_freeresult($result);
$attachments = DB()->sql_fetchrowset($result);
$num_attach = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_attach == 0)
{
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
}
if ($num_attach == 0) {
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
}
if (!($result = DB()->sql_query($total_rows_sql)))
{
bb_die('Could not query attachments #2');
}
if (!($result = DB()->sql_query($total_rows_sql))) {
bb_die('Could not query attachments #2');
}
$total_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
$total_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
return $attachments;
return $attachments;
}
/**
* perform LIMIT statement on arrays
*/
* perform LIMIT statement on arrays
*/
function limit_array($array, $start, $pagelimit)
{
// array from start - start+pagelimit
$limit = (sizeof($array) < ($start + $pagelimit)) ? sizeof($array) : $start + $pagelimit;
// array from start - start+pagelimit
$limit = (sizeof($array) < ($start + $pagelimit)) ? sizeof($array) : $start + $pagelimit;
$limit_array = array();
$limit_array = array();
for ($i = $start; $i < $limit; $i++)
{
$limit_array[] = $array[$i];
}
for ($i = $start; $i < $limit; $i++) {
$limit_array[] = $array[$i];
}
return $limit_array;
}
return $limit_array;
}

File diff suppressed because it is too large Load diff

View file

@ -1,284 +1,256 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* All Attachment Functions processing the Deletion Process
*/
* All Attachment Functions processing the Deletion Process
*/
/**
* Delete Attachment(s) from post(s) (intern)
*/
* Delete Attachment(s) from post(s) (intern)
*/
function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $user_id = 0)
{
global $bb_cfg;
global $bb_cfg;
// Generate Array, if it's not an array
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0)
{
return;
}
// Generate Array, if it's not an array
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) {
return;
}
if ($post_id_array === 0 && $attach_id_array !== 0)
{
$post_id_array = array();
if ($post_id_array === 0 && $attach_id_array !== 0) {
$post_id_array = array();
if (!is_array($attach_id_array))
{
if (strstr($attach_id_array, ', '))
{
$attach_id_array = explode(', ', $attach_id_array);
}
else if (strstr($attach_id_array, ','))
{
$attach_id_array = explode(',', $attach_id_array);
}
else
{
$attach_id = intval($attach_id_array);
$attach_id_array = array();
$attach_id_array[] = $attach_id;
}
}
if (!is_array($attach_id_array)) {
if (strstr($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
} else {
$attach_id = intval($attach_id_array);
$attach_id_array = array();
$attach_id_array[] = $attach_id;
}
}
// Get the post_ids to fill the array
$p_id = 'post_id';
// Get the post_ids to fill the array
$p_id = 'post_id';
$sql = "SELECT $p_id
$sql = "SELECT $p_id
FROM " . BB_ATTACHMENTS . '
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")
GROUP BY $p_id";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not select ids');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select ids');
}
$num_post_list = DB()->num_rows($result);
$num_post_list = DB()->num_rows($result);
if ($num_post_list == 0)
{
DB()->sql_freeresult($result);
return;
}
if ($num_post_list == 0) {
DB()->sql_freeresult($result);
return;
}
while ($row = DB()->sql_fetchrow($result))
{
$post_id_array[] = intval($row[$p_id]);
}
DB()->sql_freeresult($result);
}
while ($row = DB()->sql_fetchrow($result)) {
$post_id_array[] = intval($row[$p_id]);
}
DB()->sql_freeresult($result);
}
if (!is_array($post_id_array))
{
if (trim($post_id_array) == '')
{
return;
}
if (!is_array($post_id_array)) {
if (trim($post_id_array) == '') {
return;
}
if (strstr($post_id_array, ', '))
{
$post_id_array = explode(', ', $post_id_array);
}
else if (strstr($post_id_array, ','))
{
$post_id_array = explode(',', $post_id_array);
}
else
{
$post_id = intval($post_id_array);
if (strstr($post_id_array, ', ')) {
$post_id_array = explode(', ', $post_id_array);
} elseif (strstr($post_id_array, ',')) {
$post_id_array = explode(',', $post_id_array);
} else {
$post_id = intval($post_id_array);
$post_id_array = array();
$post_id_array[] = $post_id;
}
}
$post_id_array = array();
$post_id_array[] = $post_id;
}
}
if (!sizeof($post_id_array))
{
return;
}
if (!sizeof($post_id_array)) {
return;
}
// First of all, determine the post id and attach_id
if ($attach_id_array === 0)
{
$attach_id_array = array();
// First of all, determine the post id and attach_id
if ($attach_id_array === 0) {
$attach_id_array = array();
// Get the attach_ids to fill the array
$whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')';
// Get the attach_ids to fill the array
$whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')';
$sql = 'SELECT attach_id
$sql = 'SELECT attach_id
FROM ' . BB_ATTACHMENTS . " $whereclause
GROUP BY attach_id";
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not select attachment id #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select attachment id #1');
}
$num_attach_list = DB()->num_rows($result);
$num_attach_list = DB()->num_rows($result);
if ($num_attach_list == 0)
{
DB()->sql_freeresult($result);
return;
}
if ($num_attach_list == 0) {
DB()->sql_freeresult($result);
return;
}
while ($row = DB()->sql_fetchrow($result))
{
$attach_id_array[] = (int) $row['attach_id'];
}
DB()->sql_freeresult($result);
}
while ($row = DB()->sql_fetchrow($result)) {
$attach_id_array[] = (int)$row['attach_id'];
}
DB()->sql_freeresult($result);
}
if (!is_array($attach_id_array))
{
if (strstr($attach_id_array, ', '))
{
$attach_id_array = explode(', ', $attach_id_array);
}
else if (strstr($attach_id_array, ','))
{
$attach_id_array = explode(',', $attach_id_array);
}
else
{
$attach_id = intval($attach_id_array);
if (!is_array($attach_id_array)) {
if (strstr($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
} else {
$attach_id = intval($attach_id_array);
$attach_id_array = array();
$attach_id_array[] = $attach_id;
}
}
$attach_id_array = array();
$attach_id_array[] = $attach_id;
}
}
if (!sizeof($attach_id_array))
{
return;
}
if (!sizeof($attach_id_array)) {
return;
}
$sql_id = 'post_id';
$sql_id = 'post_id';
if (sizeof($post_id_array) && sizeof($attach_id_array))
{
$sql = 'DELETE FROM ' . BB_ATTACHMENTS . '
if (sizeof($post_id_array) && sizeof($attach_id_array)) {
$sql = 'DELETE FROM ' . BB_ATTACHMENTS . '
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")
AND $sql_id IN (" . implode(', ', $post_id_array) . ')';
if (!(DB()->sql_query($sql)))
{
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
if (!(DB()->sql_query($sql))) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
//bt
if ($sql_id == 'post_id')
{
$sql = "SELECT topic_id FROM ". BB_BT_TORRENTS ." WHERE attach_id IN(". implode(',', $attach_id_array) .")";
//bt
if ($sql_id == 'post_id') {
$sql = "SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE attach_id IN(" . implode(',', $attach_id_array) . ")";
if (!$result = DB()->sql_query($sql))
{
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
if (!$result = DB()->sql_query($sql)) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
$torrents_sql = array();
$torrents_sql = array();
while ($row = DB()->sql_fetchrow($result))
{
$torrents_sql[] = $row['topic_id'];
}
while ($row = DB()->sql_fetchrow($result)) {
$torrents_sql[] = $row['topic_id'];
}
if ($torrents_sql = implode(',', $torrents_sql))
{
// Remove peers from tracker
$sql = "DELETE FROM ". BB_BT_TRACKER ."
if ($torrents_sql = implode(',', $torrents_sql)) {
// Remove peers from tracker
$sql = "DELETE FROM " . BB_BT_TRACKER . "
WHERE topic_id IN($torrents_sql)";
if (!DB()->sql_query($sql))
{
bb_die('Could not delete peers');
}
}
// Delete torrents
$sql = "DELETE FROM ". BB_BT_TORRENTS ."
WHERE attach_id IN(". implode(',', $attach_id_array) .")";
if (!DB()->sql_query($sql)) {
bb_die('Could not delete peers');
}
}
// Delete torrents
$sql = "DELETE FROM " . BB_BT_TORRENTS . "
WHERE attach_id IN(" . implode(',', $attach_id_array) . ")";
if (!DB()->sql_query($sql))
{
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
}
//bt end
if (!DB()->sql_query($sql)) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
}
//bt end
for ($i = 0; $i < sizeof($attach_id_array); $i++)
{
$sql = 'SELECT attach_id
for ($i = 0; $i < sizeof($attach_id_array); $i++) {
$sql = 'SELECT attach_id
FROM ' . BB_ATTACHMENTS . '
WHERE attach_id = ' . (int) $attach_id_array[$i];
WHERE attach_id = ' . (int)$attach_id_array[$i];
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not select Attachment id #2');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select Attachment id #2');
}
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows == 0)
{
$sql = 'SELECT attach_id, physical_filename, thumbnail
if ($num_rows == 0) {
$sql = 'SELECT attach_id, physical_filename, thumbnail
FROM ' . BB_ATTACHMENTS_DESC . '
WHERE attach_id = ' . (int) $attach_id_array[$i];
WHERE attach_id = ' . (int)$attach_id_array[$i];
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query attach description table');
}
$num_rows = DB()->num_rows($result);
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attach description table');
}
$num_rows = DB()->num_rows($result);
if ($num_rows != 0)
{
$num_attach = $num_rows;
$attachments = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
if ($num_rows != 0) {
$num_attach = $num_rows;
$attachments = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
// delete attachments
for ($j = 0; $j < $num_attach; $j++)
{
unlink_attach($attachments[$j]['physical_filename']);
// delete attachments
for ($j = 0; $j < $num_attach; $j++) {
unlink_attach($attachments[$j]['physical_filename']);
if (intval($attachments[$j]['thumbnail']) == 1)
{
unlink_attach($attachments[$j]['physical_filename'], MODE_THUMBNAIL);
}
if (intval($attachments[$j]['thumbnail']) == 1) {
unlink_attach($attachments[$j]['physical_filename'], MODE_THUMBNAIL);
}
$sql = 'DELETE FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int) $attachments[$j]['attach_id'];
$sql = 'DELETE FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int)$attachments[$j]['attach_id'];
if (!(DB()->sql_query($sql)))
{
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
}
}
else
{
DB()->sql_freeresult($result);
}
}
}
}
if (!(DB()->sql_query($sql))) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
}
} else {
DB()->sql_freeresult($result);
}
}
}
}
// Now Sync the Topic/PM
if (sizeof($post_id_array))
{
$sql = 'SELECT topic_id
// Now Sync the Topic/PM
if (sizeof($post_id_array)) {
$sql = 'SELECT topic_id
FROM ' . BB_POSTS . '
WHERE post_id IN (' . implode(', ', $post_id_array) . ')
GROUP BY topic_id';
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not select topic id');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select topic id');
}
while ($row = DB()->sql_fetchrow($result))
{
attachment_sync_topic($row['topic_id']);
}
DB()->sql_freeresult($result);
}
}
while ($row = DB()->sql_fetchrow($result)) {
attachment_sync_topic($row['topic_id']);
}
DB()->sql_freeresult($result);
}
}

View file

@ -1,293 +1,274 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* All Attachment Functions needed to determine Special Files/Dimensions
*/
* All Attachment Functions needed to determine Special Files/Dimensions
*/
/**
* Read Long Int (4 Bytes) from File
*/
* Read Long Int (4 Bytes) from File
*/
function read_longint($fp)
{
$data = fread($fp, 4);
$data = fread($fp, 4);
$value = ord($data[0]) + (ord($data[1])<<8)+(ord($data[2])<<16)+(ord($data[3])<<24);
if ($value >= 4294967294)
{
$value -= 4294967296;
}
$value = ord($data[0]) + (ord($data[1]) << 8) + (ord($data[2]) << 16) + (ord($data[3]) << 24);
if ($value >= 4294967294) {
$value -= 4294967296;
}
return $value;
return $value;
}
/**
* Read Word (2 Bytes) from File - Note: It's an Intel Word
*/
* Read Word (2 Bytes) from File - Note: It's an Intel Word
*/
function read_word($fp)
{
$data = fread($fp, 2);
$data = fread($fp, 2);
$value = ord($data[1]) * 256 + ord($data[0]);
$value = ord($data[1]) * 256 + ord($data[0]);
return $value;
return $value;
}
/**
* Read Byte
*/
* Read Byte
*/
function read_byte($fp)
{
$data = fread($fp, 1);
$data = fread($fp, 1);
$value = ord($data);
$value = ord($data);
return $value;
return $value;
}
/**
* Get Image Dimensions
*/
* Get Image Dimensions
*/
function image_getdimension($file)
{
$size = @getimagesize($file);
$size = @getimagesize($file);
if ($size[0] != 0 || $size[1] != 0) {
return $size;
}
if ($size[0] != 0 || $size[1] != 0)
{
return $size;
}
// Try to get the Dimension manually, depending on the mimetype
$fp = @fopen($file, 'rb');
if (!$fp) {
return $size;
}
// Try to get the Dimension manually, depending on the mimetype
$fp = @fopen($file, 'rb');
if (!$fp)
{
return $size;
}
$error = false;
$error = FALSE;
// BMP - IMAGE
// BMP - IMAGE
$tmp_str = fread($fp, 2);
if ($tmp_str == 'BM') {
$length = read_longint($fp);
$tmp_str = fread($fp, 2);
if ($tmp_str == 'BM')
{
$length = read_longint($fp);
if ($length <= 6) {
$error = true;
}
if ($length <= 6)
{
$error = true;
}
if (!$error) {
$i = read_longint($fp);
if ($i != 0) {
$error = true;
}
}
if (!$error)
{
$i = read_longint($fp);
if ( $i != 0)
{
$error = true;
}
}
if (!$error) {
$i = read_longint($fp);
if (!$error)
{
$i = read_longint($fp);
if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36) {
$error = true;
}
}
if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36)
{
$error = true;
}
}
if (!$error) {
$tmp_str = fread($fp, 4);
$width = read_longint($fp);
$height = read_longint($fp);
if (!$error)
{
$tmp_str = fread($fp, 4);
$width = read_longint($fp);
$height = read_longint($fp);
if ($width > 3000 || $height > 3000) {
$error = true;
}
}
} else {
$error = true;
}
if ($width > 3000 || $height > 3000)
{
$error = true;
}
}
}
else
{
$error = true;
}
if (!$error) {
fclose($fp);
return array(
$width,
$height,
6
);
}
if (!$error)
{
fclose($fp);
return array(
$width,
$height,
6
);
}
$error = false;
fclose($fp);
$error = false;
fclose($fp);
// GIF - IMAGE
// GIF - IMAGE
$fp = @fopen($file, 'rb');
$fp = @fopen($file, 'rb');
$tmp_str = fread($fp, 3);
$tmp_str = fread($fp, 3);
if ($tmp_str == 'GIF') {
$tmp_str = fread($fp, 3);
$width = read_word($fp);
$height = read_word($fp);
if ($tmp_str == 'GIF')
{
$tmp_str = fread($fp, 3);
$width = read_word($fp);
$height = read_word($fp);
$info_byte = fread($fp, 1);
$info_byte = ord($info_byte);
if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0) {
$error = true;
}
$info_byte = fread($fp, 1);
$info_byte = ord($info_byte);
if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0)
{
$error = true;
}
if (!$error) {
if (($info_byte & 8) != 0) {
$error = true;
}
}
} else {
$error = true;
}
if (!$error)
{
if (($info_byte & 8) != 0)
{
$error = true;
}
if (!$error) {
fclose($fp);
return array(
$width,
$height,
1
);
}
}
}
else
{
$error = true;
}
$error = false;
fclose($fp);
if (!$error)
{
fclose($fp);
return array(
$width,
$height,
1
);
}
// JPG - IMAGE
$fp = @fopen($file, 'rb');
$error = false;
fclose($fp);
$tmp_str = fread($fp, 4);
$w1 = read_word($fp);
// JPG - IMAGE
$fp = @fopen($file, 'rb');
if (intval($w1) < 16) {
$error = true;
}
$tmp_str = fread($fp, 4);
$w1 = read_word($fp);
if (!$error) {
$tmp_str = fread($fp, 4);
if ($tmp_str == 'JFIF') {
$o_byte = fread($fp, 1);
if (intval($o_byte) != 0) {
$error = true;
}
if (intval($w1) < 16)
{
$error = true;
}
if (!$error) {
$str = fread($fp, 2);
$b = read_byte($fp);
if (!$error)
{
$tmp_str = fread($fp, 4);
if ($tmp_str == 'JFIF')
{
$o_byte = fread($fp, 1);
if (intval($o_byte) != 0)
{
$error = true;
}
if ($b != 0 && $b != 1 && $b != 2) {
$error = true;
}
}
if (!$error)
{
$str = fread($fp, 2);
$b = read_byte($fp);
if (!$error) {
$width = read_word($fp);
$height = read_word($fp);
if ($b != 0 && $b != 1 && $b != 2)
{
$error = true;
}
}
if ($width <= 0 || $height <= 0) {
$error = true;
}
}
}
} else {
$error = true;
}
if (!$error)
{
$width = read_word($fp);
$height = read_word($fp);
if (!$error) {
fclose($fp);
return array(
$width,
$height,
2
);
}
if ($width <= 0 || $height <= 0)
{
$error = true;
}
}
}
}
else
{
$error = true;
}
$error = false;
fclose($fp);
if (!$error)
{
fclose($fp);
return array(
$width,
$height,
2
);
}
// PCX - IMAGE
$error = false;
fclose($fp);
$fp = @fopen($file, 'rb');
// PCX - IMAGE
$tmp_str = fread($fp, 3);
$fp = @fopen($file, 'rb');
if ((ord($tmp_str[0]) == 10) && (ord($tmp_str[1]) == 0 || ord($tmp_str[1]) == 2 || ord($tmp_str[1]) == 3 || ord($tmp_str[1]) == 4 || ord($tmp_str[1]) == 5) && (ord($tmp_str[2]) == 1)) {
$b = fread($fp, 1);
$tmp_str = fread($fp, 3);
if (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24) {
$error = true;
}
if ((ord($tmp_str[0]) == 10) && (ord($tmp_str[1]) == 0 || ord($tmp_str[1]) == 2 || ord($tmp_str[1]) == 3 || ord($tmp_str[1]) == 4 || ord($tmp_str[1]) == 5) && (ord($tmp_str[2]) == 1))
{
$b = fread($fp, 1);
if (!$error) {
$xmin = read_word($fp);
$ymin = read_word($fp);
$xmax = read_word($fp);
$ymax = read_word($fp);
$tmp_str = fread($fp, 52);
if (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24)
{
$error = true;
}
$b = fread($fp, 1);
if ($b != 0) {
$error = true;
}
}
if (!$error)
{
$xmin = read_word($fp);
$ymin = read_word($fp);
$xmax = read_word($fp);
$ymax = read_word($fp);
$tmp_str = fread($fp, 52);
if (!$error) {
$width = $xmax - $xmin + 1;
$height = $ymax - $ymin + 1;
}
} else {
$error = true;
}
$b = fread($fp, 1);
if ($b != 0)
{
$error = true;
}
}
if (!$error) {
fclose($fp);
return array(
$width,
$height,
7
);
}
if (!$error)
{
$width = $xmax - $xmin + 1;
$height = $ymax - $ymin + 1;
}
}
else
{
$error = true;
}
fclose($fp);
if (!$error)
{
fclose($fp);
return array(
$width,
$height,
7
);
}
fclose($fp);
return $size;
}
return $size;
}

View file

@ -1,204 +1,187 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* Setup s_auth_can in viewforum and viewtopic (viewtopic.php/viewforum.php)
*/
* Setup s_auth_can in viewforum and viewtopic (viewtopic.php/viewforum.php)
*/
function attach_build_auth_levels($is_auth, &$s_auth_can)
{
global $lang, $attach_config;
global $lang, $attach_config;
if (intval($attach_config['disable_mod']))
{
return;
}
if (intval($attach_config['disable_mod'])) {
return;
}
// If you want to have the rules window link within the forum view too, comment out the two lines, and comment the third line
$s_auth_can .= (($is_auth['auth_attachments']) ? $lang['RULES_ATTACH_CAN'] : $lang['RULES_ATTACH_CANNOT'] ) . '<br />';
$s_auth_can .= (($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT'] ) . '<br />';
// If you want to have the rules window link within the forum view too, comment out the two lines, and comment the third line
$s_auth_can .= (($is_auth['auth_attachments']) ? $lang['RULES_ATTACH_CAN'] : $lang['RULES_ATTACH_CANNOT']) . '<br />';
$s_auth_can .= (($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT']) . '<br />';
}
/**
* Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php)
*/
* Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php)
*/
function attachment_quota_settings($admin_mode, $submit = false, $mode)
{
global $template, $lang, $attach_config;
global $template, $lang, $attach_config;
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
$upload_dir = $attach_config['upload_dir'];
}
else
{
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
}
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
$upload_dir = $attach_config['upload_dir'];
} else {
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
}
include(ATTACH_DIR .'includes/functions_selects.php');
if (!function_exists("process_quota_settings"))
include(ATTACH_DIR . 'includes/functions_admin.php');
include(ATTACH_DIR . 'includes/functions_selects.php');
if (!function_exists("process_quota_settings")) {
include(ATTACH_DIR . 'includes/functions_admin.php');
}
$user_id = 0;
$user_id = 0;
if ($admin_mode == 'user')
{
// We overwrite submit here... to be sure
$submit = (isset($_POST['submit'])) ? true : false;
if ($admin_mode == 'user') {
// We overwrite submit here... to be sure
$submit = (isset($_POST['submit'])) ? true : false;
if (!$submit && $mode != 'save')
{
$user_id = get_var(POST_USERS_URL, 0);
$u_name = get_var('username', '');
if (!$submit && $mode != 'save') {
$user_id = get_var(POST_USERS_URL, 0);
$u_name = get_var('username', '');
if (!$user_id && !$u_name)
{
bb_die($lang['NO_USER_ID_SPECIFIED'] );
}
if (!$user_id && !$u_name) {
bb_die($lang['NO_USER_ID_SPECIFIED']);
}
if ($user_id)
{
$this_userdata['user_id'] = $user_id;
}
else
{
// Get userdata is handling the sanitizing of username
$this_userdata = get_userdata($_POST['username'], true);
}
if ($user_id) {
$this_userdata['user_id'] = $user_id;
} else {
// Get userdata is handling the sanitizing of username
$this_userdata = get_userdata($_POST['username'], true);
}
$user_id = (int) $this_userdata['user_id'];
}
else
{
$user_id = get_var('id', 0);
$user_id = (int)$this_userdata['user_id'];
} else {
$user_id = get_var('id', 0);
if (!$user_id)
{
bb_die($lang['NO_USER_ID_SPECIFIED'] );
}
}
}
if (!$user_id) {
bb_die($lang['NO_USER_ID_SPECIFIED']);
}
}
}
if ($admin_mode == 'user' && !$submit && $mode != 'save')
{
// Show the contents
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE user_id = ' . (int) $user_id;
if ($admin_mode == 'user' && !$submit && $mode != 'save') {
// Show the contents
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE user_id = ' . (int)$user_id;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Unable to get quota settings #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to get quota settings #1');
}
$pm_quota = $upload_quota = 0;
$pm_quota = $upload_quota = 0;
if ($row = DB()->sql_fetchrow($result))
{
do
{
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT)
{
$upload_quota = $row['quota_limit_id'];
}
else if ($row['quota_type'] == QUOTA_PM_LIMIT)
{
$pm_quota = $row['quota_limit_id'];
}
}
while ($row = DB()->sql_fetchrow($result));
}
else
{
// Set Default Quota Limit
$upload_quota = $attach_config['default_upload_quota'];
$pm_quota = $attach_config['default_pm_quota'];
if ($row = DB()->sql_fetchrow($result)) {
do {
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) {
$upload_quota = $row['quota_limit_id'];
} elseif ($row['quota_type'] == QUOTA_PM_LIMIT) {
$pm_quota = $row['quota_limit_id'];
}
} while ($row = DB()->sql_fetchrow($result));
} else {
// Set Default Quota Limit
$upload_quota = $attach_config['default_upload_quota'];
$pm_quota = $attach_config['default_pm_quota'];
}
DB()->sql_freeresult($result);
}
DB()->sql_freeresult($result);
$template->assign_vars(array(
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota),
));
}
$template->assign_vars(array(
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota),
));
}
if ($admin_mode == 'user' && $submit && @$_POST['delete_user']) {
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0);
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0);
} elseif ($admin_mode == 'user' && $submit && $mode == 'save') {
// Get the contents
$upload_quota = get_var('user_upload_quota', 0);
$pm_quota = get_var('user_pm_quota', 0);
if ($admin_mode == 'user' && $submit && @$_POST['delete_user'])
{
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0);
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0);
}
else if ($admin_mode == 'user' && $submit && $mode == 'save')
{
// Get the contents
$upload_quota = get_var('user_upload_quota', 0);
$pm_quota = get_var('user_pm_quota', 0);
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota);
}
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota);
}
if ($admin_mode == 'group' && $mode == 'newgroup') {
return;
}
if ($admin_mode == 'group' && $mode == 'newgroup')
{
return;
}
if ($admin_mode == 'group' && !$submit && isset($_POST['edit'])) {
// Get group id again
$group_id = get_var(POST_GROUPS_URL, 0);
if ($admin_mode == 'group' && !$submit && isset($_POST['edit']))
{
// Get group id again
$group_id = get_var(POST_GROUPS_URL, 0);
// Show the contents
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE group_id = ' . (int)$group_id;
// Show the contents
$sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE group_id = ' . (int) $group_id;
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to get quota settings #2');
}
if (!($result = DB()->sql_query($sql)))
{
bb_die('Unable to get quota settings #2');
}
$pm_quota = $upload_quota = 0;
$pm_quota = $upload_quota = 0;
if ($row = DB()->sql_fetchrow($result)) {
do {
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) {
$upload_quota = $row['quota_limit_id'];
} elseif ($row['quota_type'] == QUOTA_PM_LIMIT) {
$pm_quota = $row['quota_limit_id'];
}
} while ($row = DB()->sql_fetchrow($result));
} else {
// Set Default Quota Limit
$upload_quota = $attach_config['default_upload_quota'];
$pm_quota = $attach_config['default_pm_quota'];
}
DB()->sql_freeresult($result);
if ($row = DB()->sql_fetchrow($result))
{
do
{
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT)
{
$upload_quota = $row['quota_limit_id'];
}
else if ($row['quota_type'] == QUOTA_PM_LIMIT)
{
$pm_quota = $row['quota_limit_id'];
}
}
while ($row = DB()->sql_fetchrow($result));
}
else
{
// Set Default Quota Limit
$upload_quota = $attach_config['default_upload_quota'];
$pm_quota = $attach_config['default_pm_quota'];
}
DB()->sql_freeresult($result);
$template->assign_vars(array(
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota),
));
}
$template->assign_vars(array(
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota),
));
}
if ($admin_mode == 'group' && $submit && isset($_POST['group_delete'])) {
$group_id = get_var(POST_GROUPS_URL, 0);
if ($admin_mode == 'group' && $submit && isset($_POST['group_delete']))
{
$group_id = get_var(POST_GROUPS_URL, 0);
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0);
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0);
} elseif ($admin_mode == 'group' && $submit) {
$group_id = get_var(POST_GROUPS_URL, 0);
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0);
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0);
}
else if ($admin_mode == 'group' && $submit)
{
$group_id = get_var(POST_GROUPS_URL, 0);
// Get the contents
$upload_quota = get_var('group_upload_quota', 0);
$pm_quota = get_var('group_pm_quota', 0);
// Get the contents
$upload_quota = get_var('group_upload_quota', 0);
$pm_quota = get_var('group_pm_quota', 0);
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota);
}
}
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota);
}
}

View file

@ -1,251 +1,245 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* Functions to build select boxes ;)
*/
* Functions to build select boxes ;)
*/
/**
* select group
*/
* select group
*/
function group_select($select_name, $default_group = 0)
{
global $lang;
global $lang;
$sql = 'SELECT group_id, group_name FROM ' . BB_EXTENSION_GROUPS . ' ORDER BY group_name';
$sql = 'SELECT group_id, group_name FROM ' . BB_EXTENSION_GROUPS . ' ORDER BY group_name';
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query extension groups table #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query extension groups table #1');
}
$group_select = '<select name="' . $select_name . '">';
$group_select = '<select name="' . $select_name . '">';
$group_name = DB()->sql_fetchrowset($result);
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
$group_name = DB()->sql_fetchrowset($result);
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows > 0)
{
$group_name[$num_rows]['group_id'] = 0;
$group_name[$num_rows]['group_name'] = $lang['NOT_ASSIGNED'];
if ($num_rows > 0) {
$group_name[$num_rows]['group_id'] = 0;
$group_name[$num_rows]['group_name'] = $lang['NOT_ASSIGNED'];
for ($i = 0; $i < sizeof($group_name); $i++)
{
if (!$default_group)
{
$selected = ($i == 0) ? ' selected="selected"' : '';
}
else
{
$selected = ($group_name[$i]['group_id'] == $default_group) ? ' selected="selected"' : '';
}
for ($i = 0; $i < sizeof($group_name); $i++) {
if (!$default_group) {
$selected = ($i == 0) ? ' selected="selected"' : '';
} else {
$selected = ($group_name[$i]['group_id'] == $default_group) ? ' selected="selected"' : '';
}
$group_select .= '<option value="' . $group_name[$i]['group_id'] . '"' . $selected . '>' . $group_name[$i]['group_name'] . '</option>';
}
}
$group_select .= '<option value="' . $group_name[$i]['group_id'] . '"' . $selected . '>' . $group_name[$i]['group_name'] . '</option>';
}
}
$group_select .= '</select>';
$group_select .= '</select>';
return $group_select;
return $group_select;
}
/**
* select download mode
*/
* select download mode
*/
function download_select($select_name, $group_id = 0)
{
global $types_download, $modes_download;
global $types_download, $modes_download;
if ($group_id)
{
$sql = 'SELECT download_mode
if ($group_id) {
$sql = 'SELECT download_mode
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id = ' . (int) $group_id;
WHERE group_id = ' . (int)$group_id;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query extension groups table #2');
}
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query extension groups table #2');
}
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
if (!isset($row['download_mode']))
{
return '';
}
if (!isset($row['download_mode'])) {
return '';
}
$download_mode = $row['download_mode'];
}
$download_mode = $row['download_mode'];
}
$group_select = '<select name="' . $select_name . '">';
$group_select = '<select name="' . $select_name . '">';
for ($i = 0; $i < sizeof($types_download); $i++)
{
if (!$group_id)
{
$selected = ($types_download[$i] == INLINE_LINK) ? ' selected="selected"' : '';
}
else
{
$selected = ($row['download_mode'] == $types_download[$i]) ? ' selected="selected"' : '';
}
for ($i = 0; $i < sizeof($types_download); $i++) {
if (!$group_id) {
$selected = ($types_download[$i] == INLINE_LINK) ? ' selected="selected"' : '';
} else {
$selected = ($row['download_mode'] == $types_download[$i]) ? ' selected="selected"' : '';
}
$group_select .= '<option value="' . $types_download[$i] . '"' . $selected . '>' . $modes_download[$i] . '</option>';
}
$group_select .= '<option value="' . $types_download[$i] . '"' . $selected . '>' . $modes_download[$i] . '</option>';
}
$group_select .= '</select>';
$group_select .= '</select>';
return $group_select;
return $group_select;
}
/**
* select category types
*/
* select category types
*/
function category_select($select_name, $group_id = 0)
{
global $types_category, $modes_category;
global $types_category, $modes_category;
$sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS;
$sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS;
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not select category');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select category');
}
$rows = DB()->sql_fetchrowset($result);
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
$rows = DB()->sql_fetchrowset($result);
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
$type_category = 0;
$type_category = 0;
if ($num_rows > 0)
{
for ($i = 0; $i < $num_rows; $i++)
{
if ($group_id == $rows[$i]['group_id'])
{
$category_type = $rows[$i]['cat_id'];
}
}
}
if ($num_rows > 0) {
for ($i = 0; $i < $num_rows; $i++) {
if ($group_id == $rows[$i]['group_id']) {
$category_type = $rows[$i]['cat_id'];
}
}
}
$types = array(NONE_CAT);
$modes = array('none');
$types = array(NONE_CAT);
$modes = array('none');
for ($i = 0; $i < sizeof($types_category); $i++)
{
$types[] = $types_category[$i];
$modes[] = $modes_category[$i];
}
for ($i = 0; $i < sizeof($types_category); $i++) {
$types[] = $types_category[$i];
$modes[] = $modes_category[$i];
}
$group_select = '<select name="' . $select_name . '" style="width:100px">';
$group_select = '<select name="' . $select_name . '" style="width:100px">';
for ($i = 0; $i < sizeof($types); $i++)
{
if (!$group_id)
{
$selected = ($types[$i] == NONE_CAT) ? ' selected="selected"' : '';
}
else
{
$selected = ($types[$i] == $category_type) ? ' selected="selected"' : '';
}
for ($i = 0; $i < sizeof($types); $i++) {
if (!$group_id) {
$selected = ($types[$i] == NONE_CAT) ? ' selected="selected"' : '';
} else {
$selected = ($types[$i] == $category_type) ? ' selected="selected"' : '';
}
$group_select .= '<option value="' . $types[$i] . '"' . $selected . '>' . $modes[$i] . '</option>';
}
$group_select .= '<option value="' . $types[$i] . '"' . $selected . '>' . $modes[$i] . '</option>';
}
$group_select .= '</select>';
$group_select .= '</select>';
return $group_select;
return $group_select;
}
/**
* Select size mode
*/
* Select size mode
*/
function size_select($select_name, $size_compare)
{
global $lang;
global $lang;
$size_types_text = array($lang['BYTES'], $lang['KB'], $lang['MB']);
$size_types = array('b', 'kb', 'mb');
$size_types_text = array($lang['BYTES'], $lang['KB'], $lang['MB']);
$size_types = array('b', 'kb', 'mb');
$select_field = '<select name="' . $select_name . '">';
$select_field = '<select name="' . $select_name . '">';
for ($i = 0; $i < sizeof($size_types_text); $i++)
{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
}
for ($i = 0; $i < sizeof($size_types_text); $i++) {
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
}
$select_field .= '</select>';
$select_field .= '</select>';
return $select_field;
return $select_field;
}
/**
* select quota limit
*/
* select quota limit
*/
function quota_limit_select($select_name, $default_quota = 0)
{
global $lang;
global $lang;
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query quota limits table #1');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query quota limits table #1');
}
$quota_select = '<select name="' . $select_name . '">';
$quota_name[0]['quota_limit_id'] = 0;
$quota_name[0]['quota_desc'] = $lang['NOT_ASSIGNED'];
$quota_select = '<select name="' . $select_name . '">';
$quota_name[0]['quota_limit_id'] = 0;
$quota_name[0]['quota_desc'] = $lang['NOT_ASSIGNED'];
while ($row = DB()->sql_fetchrow($result))
{
$quota_name[] = $row;
}
DB()->sql_freeresult($result);
while ($row = DB()->sql_fetchrow($result)) {
$quota_name[] = $row;
}
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($quota_name); $i++)
{
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}
$quota_select .= '</select>';
for ($i = 0; $i < sizeof($quota_name); $i++) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}
$quota_select .= '</select>';
return $quota_select;
return $quota_select;
}
/**
* select default quota limit
*/
* select default quota limit
*/
function default_quota_limit_select($select_name, $default_quota = 0)
{
global $lang;
global $lang;
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
if (!($result = DB()->sql_query($sql)))
{
bb_die('Could not query quota limits table #2');
}
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query quota limits table #2');
}
$quota_select = '<select name="' . $select_name . '">';
$quota_name[0]['quota_limit_id'] = 0;
$quota_name[0]['quota_desc'] = $lang['NO_QUOTA_LIMIT'];
$quota_select = '<select name="' . $select_name . '">';
$quota_name[0]['quota_limit_id'] = 0;
$quota_name[0]['quota_desc'] = $lang['NO_QUOTA_LIMIT'];
while ($row = DB()->sql_fetchrow($result))
{
$quota_name[] = $row;
}
DB()->sql_freeresult($result);
while ($row = DB()->sql_fetchrow($result)) {
$quota_name[] = $row;
}
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($quota_name); $i++)
{
$selected = ( $quota_name[$i]['quota_limit_id'] == $default_quota ) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}
$quota_select .= '</select>';
for ($i = 0; $i < sizeof($quota_name); $i++) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}
$quota_select .= '</select>';
return $quota_select;
}
return $quota_select;
}

View file

@ -1,189 +1,194 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('IN_FORUM')) die("Hacking attempt");
if (!defined('IN_FORUM')) {
die("Hacking attempt");
}
$imagick = '';
/**
* Calculate the needed size for Thumbnail
*/
* Calculate the needed size for Thumbnail
*/
function get_img_size_format($width, $height)
{
// Maximum Width the Image can take
$max_width = 400;
// Maximum Width the Image can take
$max_width = 400;
if ($width > $height)
{
return array(
round($width * ($max_width / $width)),
round($height * ($max_width / $width))
);
}
else
{
return array(
round($width * ($max_width / $height)),
round($height * ($max_width / $height))
);
}
if ($width > $height) {
return array(
round($width * ($max_width / $width)),
round($height * ($max_width / $width))
);
} else {
return array(
round($width * ($max_width / $height)),
round($height * ($max_width / $height))
);
}
}
/**
* Check if imagick is present
*/
* Check if imagick is present
*/
function is_imagick()
{
global $imagick, $attach_config;
global $imagick, $attach_config;
if ($attach_config['img_imagick'] != '')
{
$imagick = $attach_config['img_imagick'];
return true;
}
else
{
return false;
}
if ($attach_config['img_imagick'] != '') {
$imagick = $attach_config['img_imagick'];
return true;
} else {
return false;
}
}
/**
* Get supported image types
*/
* Get supported image types
*/
function get_supported_image_types($type)
{
if (@extension_loaded('gd'))
{
$format = imagetypes();
$new_type = 0;
if (@extension_loaded('gd')) {
$format = imagetypes();
$new_type = 0;
switch ($type)
{
case 1:
$new_type = ($format & IMG_GIF) ? IMG_GIF : 0;
break;
case 2:
case 9:
case 10:
case 11:
case 12:
$new_type = ($format & IMG_JPG) ? IMG_JPG : 0;
break;
case 3:
$new_type = ($format & IMG_PNG) ? IMG_PNG : 0;
break;
case 6:
case 15:
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0;
break;
}
switch ($type) {
case 1:
$new_type = ($format & IMG_GIF) ? IMG_GIF : 0;
break;
case 2:
case 9:
case 10:
case 11:
case 12:
$new_type = ($format & IMG_JPG) ? IMG_JPG : 0;
break;
case 3:
$new_type = ($format & IMG_PNG) ? IMG_PNG : 0;
break;
case 6:
case 15:
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0;
break;
}
return array(
'gd' => ($new_type) ? true : false,
'format' => $new_type,
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
);
}
return array(
'gd' => ($new_type) ? true : false,
'format' => $new_type,
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
);
}
return array('gd' => false);
return array('gd' => false);
}
/**
* Create thumbnail
*/
* Create thumbnail
*/
function create_thumbnail($source, $new_file, $mimetype)
{
global $attach_config, $imagick;
global $attach_config, $imagick;
$source = amod_realpath($source);
$min_filesize = (int) $attach_config['img_min_thumb_filesize'];
$img_filesize = (@file_exists($source)) ? @filesize($source) : false;
$source = amod_realpath($source);
$min_filesize = (int)$attach_config['img_min_thumb_filesize'];
$img_filesize = (@file_exists($source)) ? @filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize)
{
return false;
}
if (!$img_filesize || $img_filesize <= $min_filesize) {
return false;
}
list($width, $height, $type, ) = getimagesize($source);
list($width, $height, $type,) = getimagesize($source);
if (!$width || !$height)
{
return false;
}
if (!$width || !$height) {
return false;
}
list($new_width, $new_height) = get_img_size_format($width, $height);
list($new_width, $new_height) = get_img_size_format($width, $height);
$tmp_path = $old_file = '';
$tmp_path = $old_file = '';
$used_imagick = false;
$used_imagick = false;
if (is_imagick())
{
passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
if (@file_exists($new_file))
{
$used_imagick = true;
}
}
if (is_imagick()) {
passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
if (@file_exists($new_file)) {
$used_imagick = true;
}
}
if (!$used_imagick)
{
$type = get_supported_image_types($type);
if (!$used_imagick) {
$type = get_supported_image_types($type);
if ($type['gd'])
{
switch ($type['format'])
{
case IMG_GIF:
$image = imagecreatefromgif($source);
break;
case IMG_JPG:
$image = imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = imagecreatefromwbmp($source);
break;
}
if ($type['gd']) {
switch ($type['format']) {
case IMG_GIF:
$image = imagecreatefromgif($source);
break;
case IMG_JPG:
$image = imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = imagecreatefromwbmp($source);
break;
}
if ($type['version'] == 1 || !$attach_config['use_gd2'])
{
$new_image = imagecreate($new_width, $new_height);
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
else
{
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
if ($type['version'] == 1 || !$attach_config['use_gd2']) {
$new_image = imagecreate($new_width, $new_height);
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
} else {
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
switch ($type['format'])
{
case IMG_GIF:
imagegif($new_image, $new_file);
break;
case IMG_JPG:
imagejpeg($new_image, $new_file, 90);
break;
case IMG_PNG:
imagepng($new_image, $new_file);
break;
case IMG_WBMP:
imagewbmp($new_image, $new_file);
break;
}
switch ($type['format']) {
case IMG_GIF:
imagegif($new_image, $new_file);
break;
case IMG_JPG:
imagejpeg($new_image, $new_file, 90);
break;
case IMG_PNG:
imagepng($new_image, $new_file);
break;
case IMG_WBMP:
imagewbmp($new_image, $new_file);
break;
}
imagedestroy($new_image);
}
}
imagedestroy($new_image);
}
}
if (!@file_exists($new_file))
{
return false;
}
if (!@file_exists($new_file)) {
return false;
}
@chmod($new_file, 0664);
@chmod($new_file, 0664);
return true;
}
return true;
}

File diff suppressed because it is too large Load diff

View file

@ -1,28 +1,51 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* Script versions
* Domain name
* Version info
* Database
- Charset
- Config
- Aliases
* - Charset
* - Config
* - Aliases
* Cache
- Config
- Datastore
* - Config
* - Datastore
* Server
- Cloudflare
- GZip
* - Cloudflare
* - GZip
* Tracker
* Ocelot
* FAQ url
* Torrents
- Ratio limits
- Seeding torrents limit
- DL-Status (days to keep)
- Tor-Stats (days to keep)
- Tor-Help
* - Ratio limits
* - Seeding torrents limit
* - DL-Status (days to keep)
* - Tor-Stats (days to keep)
* - Tor-Help
* Path
* URL's
* Language
@ -58,9 +81,11 @@
* Atom feed
* Nofollow
* Local config
**/
**/
if (!defined('BB_ROOT')) die(basename(__FILE__));
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$bb_cfg = $tr_cfg = $page_cfg = array();
@ -78,59 +103,59 @@ $bb_cfg['tp_release_state'] = 'ALPHA';
$bb_cfg['tp_zf_version'] = '2.3.3';
// Database
$charset = 'utf8';
$charset = 'utf8';
$pconnect = false;
// Настройка баз данных ['db']['srv_name'] => (array) srv_cfg;
// порядок параметров srv_cfg (хост, название базы, пользователь, пароль, charset, pconnect);
$bb_cfg['db'] = array(
'db1' => array('localhost', 'tp_215', 'user', 'pass', $charset, $pconnect),
//'db2' => array('localhost2', 'dbase2', 'user2', 'pass2', $charset, $pconnect),
//'db3' => array('localhost3', 'dbase3', 'user2', 'pass3', $charset, $pconnect),
'db1' => array('localhost', 'tp_215', 'user', 'pass', $charset, $pconnect),
//'db2' => array('localhost2', 'dbase2', 'user2', 'pass2', $charset, $pconnect),
//'db3' => array('localhost3', 'dbase3', 'user2', 'pass3', $charset, $pconnect),
);
$bb_cfg['db_alias'] = array(
// 'alias' => 'srv_name'
# db1
'log' => 'db1', // BB_LOG
'search' => 'db1', // BB_TOPIC_SEARCH
'sres' => 'db1', // BB_BT_USER_SETTINGS, BB_SEARCH_RESULTS
'u_ses' => 'db1', // BB_USER_SES, BB_USER_LASTVISIT
'log' => 'db1', // BB_LOG
'search' => 'db1', // BB_TOPIC_SEARCH
'sres' => 'db1', // BB_BT_USER_SETTINGS, BB_SEARCH_RESULTS
'u_ses' => 'db1', // BB_USER_SES, BB_USER_LASTVISIT
# db2
'dls' => 'db1', // BB_BT_DLS_*
'ip' => 'db1', // BB_POSTS_IP
'ut' => 'db1', // BB_TOPICS_USER_POSTED
'dls' => 'db1', // BB_BT_DLS_*
'ip' => 'db1', // BB_POSTS_IP
'ut' => 'db1', // BB_TOPICS_USER_POSTED
# db3
'pm' => 'db1', // BB_PRIVMSGS, BB_PRIVMSGS_TEXT
'pt' => 'db1', // BB_POSTS_TEXT
'pm' => 'db1', // BB_PRIVMSGS, BB_PRIVMSGS_TEXT
'pt' => 'db1', // BB_POSTS_TEXT
);
// Cache
$bb_cfg['cache']['pconnect'] = true;
$bb_cfg['cache']['db_dir'] = realpath(BB_ROOT) .'/internal_data/cache/filecache/';
$bb_cfg['cache']['prefix'] = 'tp_'; // Префикс кеша ('tp_')
$bb_cfg['cache']['db_dir'] = realpath(BB_ROOT) . '/internal_data/cache/filecache/';
$bb_cfg['cache']['prefix'] = 'tp_'; // Префикс кеша ('tp_')
$bb_cfg['cache']['memcache'] = array(
'host' => '127.0.0.1',
'port' => 11211,
'pconnect' => true,
'con_required' => true,
'host' => '127.0.0.1',
'port' => 11211,
'pconnect' => true,
'con_required' => true,
);
$bb_cfg['cache']['redis'] = array(
'host' => '127.0.0.1',
'port' => 6379,
'con_required' => true,
$bb_cfg['cache']['redis'] = array(
'host' => '127.0.0.1',
'port' => 6379,
'con_required' => true,
);
// Available cache types: memcache, sqlite, redis, apc, xcache (default of filecache)
# name => array( (string) type, (array) cfg )
$bb_cfg['cache']['engines'] = array(
'bb_cache' => array('filecache', array()),
'bb_config' => array('filecache', array()),
'tr_cache' => array('filecache', array()),
'session_cache' => array('filecache', array()),
'bb_cap_sid' => array('filecache', array()),
'bb_login_err' => array('filecache', array()),
'bb_poll_data' => array('filecache', array()),
'bb_cache' => array('filecache', array()),
'bb_config' => array('filecache', array()),
'tr_cache' => array('filecache', array()),
'session_cache' => array('filecache', array()),
'bb_cap_sid' => array('filecache', array()),
'bb_login_err' => array('filecache', array()),
'bb_poll_data' => array('filecache', array()),
);
// Datastore
// Available datastore types: memcache, sqlite, redis, apc, xcache (default filecache)
@ -142,76 +167,75 @@ $bb_cfg['server_port'] = (!empty($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PO
$bb_cfg['script_path'] = '/'; // The path where FORUM is located relative to the domain name
// Cloudflare
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
// GZip
$bb_cfg['gzip_compress'] = true; // compress output
$bb_cfg['gzip_compress'] = true; // compress output
// Tracker
$bb_cfg['announce_interval'] = 2400; // Announce interval (default: 1800)
$bb_cfg['passkey_key'] = 'uk'; // Passkey key name in GET request
$bb_cfg['announce_interval'] = 2400; // Announce interval (default: 1800)
$bb_cfg['passkey_key'] = 'uk'; // Passkey key name in GET request
$bb_cfg['ignore_reported_ip'] = false; // Ignore IP reported by client
$bb_cfg['verify_reported_ip'] = true; // Verify IP reported by client against $_SERVER['HTTP_X_FORWARDED_FOR']
$bb_cfg['allow_internal_ip'] = false; // Allow internal IP (10.xx.. etc.)
$bb_cfg['allow_internal_ip'] = false; // Allow internal IP (10.xx.. etc.)
// Ocelot
$bb_cfg['ocelot'] = array(
'enabled' => false,
'host' => $domain_name,
'port' => 34000,
'url' => "http://$domain_name:34000/", // with '/'
'secret' => 'some_10_chars', // 10 chars
'stats' => 'some_10_chars', // 10 chars
'enabled' => false,
'host' => $domain_name,
'port' => 34000,
'url' => "http://$domain_name:34000/", // with '/'
'secret' => 'some_10_chars', // 10 chars
'stats' => 'some_10_chars', // 10 chars
);
// FAQ url help link
$bb_cfg['how_to_download_url_help'] = 'viewtopic.php?t=1'; // Как скачивать?
$bb_cfg['what_is_torrent_url_help'] = 'viewtopic.php?t=2'; // Что такое торрент?
$bb_cfg['ratio_url_help'] = 'viewtopic.php?t=3'; // Рейтинг и ограничения
$bb_cfg['search_help_url'] = 'viewtopic.php?t=4'; // Помощь по поиску
$bb_cfg['how_to_download_url_help'] = 'viewtopic.php?t=1'; // Как скачивать?
$bb_cfg['what_is_torrent_url_help'] = 'viewtopic.php?t=2'; // Что такое торрент?
$bb_cfg['ratio_url_help'] = 'viewtopic.php?t=3'; // Рейтинг и ограничения
$bb_cfg['search_help_url'] = 'viewtopic.php?t=4'; // Помощь по поиску
// Torrents
$bb_cfg['bt_min_ratio_allow_dl_tor'] = 0.3; // 0 - disable
$bb_cfg['bt_min_ratio_warning'] = 0.6; // 0 - disable
$bb_cfg['bt_min_ratio_warning'] = 0.6; // 0 - disable
$tr_cfg = array(
'autoclean' => true,
'off' => false,
'off_reason' => 'temporarily disabled',
'numwant' => 50,
'update_dlstat' => true,
'expire_factor' => 2.5,
'compact_mode' => true,
'upd_user_up_down_stat' => true,
'browser_redirect_url' => '',
'scrape' => true,
'limit_active_tor' => true,
'limit_seed_count' => 0,
'limit_leech_count' => 8,
'leech_expire_factor' => 60,
'limit_concurrent_ips' => false,
'limit_seed_ips' => 0,
'limit_leech_ips' => 0,
'tor_topic_up' => true,
'gold_silver_enabled' => true,
'retracker' => true,
'retracker_host' => 'http://retracker.local/announce',
'autoclean' => true,
'off' => false,
'off_reason' => 'temporarily disabled',
'numwant' => 50,
'update_dlstat' => true,
'expire_factor' => 2.5,
'compact_mode' => true,
'upd_user_up_down_stat' => true,
'browser_redirect_url' => '',
'scrape' => true,
'limit_active_tor' => true,
'limit_seed_count' => 0,
'limit_leech_count' => 8,
'leech_expire_factor' => 60,
'limit_concurrent_ips' => false,
'limit_seed_ips' => 0,
'limit_leech_ips' => 0,
'tor_topic_up' => true,
'gold_silver_enabled' => true,
'retracker' => true,
'retracker_host' => 'http://retracker.local/announce',
);
$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['torrent_name_style'] = true; // use torrent name style [yoursite.com].txxx.torrent
$bb_cfg['tor_help_links'] = 'terms.php';
$bb_cfg['tor_help_links'] = 'terms.php';
// Сколько дней сохранять торрент зарегистрированным / Days to keep torrent registered, if:
$bb_cfg['seeder_last_seen_days_keep'] = 0; // сколько дней назад был сид последний раз
$bb_cfg['seeder_last_seen_days_keep'] = 0; // сколько дней назад был сид последний раз
$bb_cfg['seeder_never_seen_days_keep'] = 0; // сколько дней имеется статус "Сида не было никогда"
// Ratio limits
@ -224,116 +248,107 @@ define('MIN_DL_FOR_RATIO', 10737418240); // 10 GB in bytes, 0 - disable
// rating < 0.6 -- only 3
// rating > 0.6 -- depend on your tracker config limits (in "ACP - Tracker Config - Limits")
$rating_limits = array(
'0.4' => 1,
'0.5' => 2,
'0.6' => 3,
'0.4' => 1,
'0.5' => 2,
'0.6' => 3,
);
// DL-Status (days to keep user's dlstatus records)
$bb_cfg['dl_will_days_keep'] = 360;
$bb_cfg['dl_down_days_keep'] = 180;
$bb_cfg['dl_will_days_keep'] = 360;
$bb_cfg['dl_down_days_keep'] = 180;
$bb_cfg['dl_complete_days_keep'] = 180;
$bb_cfg['dl_cancel_days_keep'] = 30;
$bb_cfg['dl_cancel_days_keep'] = 30;
// Tor-Stats
$bb_cfg['torstat_days_keep'] = 60; // days to keep user's per-torrent stats
$bb_cfg['torstat_days_keep'] = 60; // days to keep user's per-torrent stats
// Tor-Help
$bb_cfg['torhelp_enabled'] = false; // find dead torrents (without seeder) that user might help seeding
$bb_cfg['torhelp_enabled'] = false; // find dead torrents (without seeder) that user might help seeding
$page_cfg['show_torhelp'] = array(
# BB_SCRIPT => true
'index' => true,
'tracker' => true,
'index' => true,
'tracker' => true,
);
// Path (trailing slash '/' at the end: XX_PATH - without, XX_DIR - with)
define('BB_PATH', realpath(BB_ROOT) );
define('ADMIN_DIR', BB_PATH .'/admin/' );
define('DATA_DIR', BB_PATH .'/data/' );
define('INT_DATA_DIR', BB_PATH .'/internal_data/' );
define('AJAX_HTML_DIR', BB_ROOT .'/internal_data/ajax_html/' );
define('CACHE_DIR', BB_PATH .'/internal_data/cache/' );
define('LOG_DIR', BB_PATH .'/internal_data/log/' );
define('SITEMAP_DIR', BB_PATH .'/internal_data/sitemap/' );
define('TRIGGERS_DIR', BB_PATH .'/internal_data/triggers/' );
define('AJAX_DIR', BB_ROOT .'/library/ajax/' );
define('ATTACH_DIR', BB_PATH .'/library/attach_mod/' );
define('CFG_DIR', BB_PATH .'/library/config/' );
define('INC_DIR', BB_PATH .'/library/includes/' );
define('CLASS_DIR', BB_PATH .'/library/includes/classes/');
define('CORE_DIR', BB_PATH .'/library/includes/core/' );
define('UCP_DIR', BB_PATH .'/library/includes/ucp/' );
define('LANG_ROOT_DIR', BB_PATH .'/library/language/' );
define('IMAGES_DIR', BB_PATH .'/styles/images/' );
define('TEMPLATES_DIR', BB_PATH .'/styles/templates/' );
define('BB_PATH', realpath(BB_ROOT));
define('ADMIN_DIR', BB_PATH . '/admin/');
define('DATA_DIR', BB_PATH . '/data/');
define('INT_DATA_DIR', BB_PATH . '/internal_data/');
define('AJAX_HTML_DIR', BB_ROOT . '/internal_data/ajax_html/');
define('CACHE_DIR', BB_PATH . '/internal_data/cache/');
define('LOG_DIR', BB_PATH . '/internal_data/log/');
define('SITEMAP_DIR', BB_PATH . '/internal_data/sitemap/');
define('TRIGGERS_DIR', BB_PATH . '/internal_data/triggers/');
define('AJAX_DIR', BB_ROOT . '/library/ajax/');
define('ATTACH_DIR', BB_PATH . '/library/attach_mod/');
define('CFG_DIR', BB_PATH . '/library/config/');
define('INC_DIR', BB_PATH . '/library/includes/');
define('CLASS_DIR', BB_PATH . '/library/includes/classes/');
define('CORE_DIR', BB_PATH . '/library/includes/core/');
define('UCP_DIR', BB_PATH . '/library/includes/ucp/');
define('LANG_ROOT_DIR', BB_PATH . '/library/language/');
define('IMAGES_DIR', BB_PATH . '/styles/images/');
define('TEMPLATES_DIR', BB_PATH . '/styles/templates/');
// URL's
$bb_cfg['ajax_url'] = 'ajax.php'; # "http://{$_SERVER['SERVER_NAME']}/ajax.php"
$bb_cfg['login_url'] = 'login.php'; # "http://{$domain_name}/login.php"
$bb_cfg['ajax_url'] = 'ajax.php'; # "http://{$_SERVER['SERVER_NAME']}/ajax.php"
$bb_cfg['login_url'] = 'login.php'; # "http://{$domain_name}/login.php"
$bb_cfg['posting_url'] = 'posting.php'; # "http://{$domain_name}/posting.php"
$bb_cfg['pm_url'] = 'privmsg.php'; # "http://{$domain_name}/privmsg.php"
$bb_cfg['pm_url'] = 'privmsg.php'; # "http://{$domain_name}/privmsg.php"
// Language
$bb_cfg['charset'] = 'utf8'; // page charset
$bb_cfg['charset'] = 'utf8'; // page charset
$bb_cfg['auto_language'] = true; // select user-preferred language automatically
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && $bb_cfg['auto_language'])
{
$user_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if (file_exists(LANG_ROOT_DIR . $user_lang .'/'))
{
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR . $user_lang .'/';
$bb_cfg['default_lang'] = $user_lang;
}
else
{
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR .'en/';
$bb_cfg['default_lang'] = 'en';
}
}
else
{
if (isset($bb_cfg['default_lang']) && file_exists(LANG_ROOT_DIR . $bb_cfg['default_lang'] .'/'))
{
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR . $bb_cfg['default_lang'] .'/';
}
else
{
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR .'en/';
}
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && $bb_cfg['auto_language']) {
$user_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if (file_exists(LANG_ROOT_DIR . $user_lang . '/')) {
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR . $user_lang . '/';
$bb_cfg['default_lang'] = $user_lang;
} else {
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR . 'en/';
$bb_cfg['default_lang'] = 'en';
}
} else {
if (isset($bb_cfg['default_lang']) && file_exists(LANG_ROOT_DIR . $bb_cfg['default_lang'] . '/')) {
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR . $bb_cfg['default_lang'] . '/';
} else {
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR . 'en/';
}
}
$bb_cfg['lang'] = array(
'ru' => array(
'name' => 'Русский',
'locale' => 'ru_RU.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'ru',
),
'uk' => array(
'name' => 'Український',
'locale' => 'uk_UA.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'uk',
),
'en' => array(
'name' => 'English',
'locale' => 'en_US.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'en',
),
'ru' => array(
'name' => 'Русский',
'locale' => 'ru_RU.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'ru',
),
'uk' => array(
'name' => 'Український',
'locale' => 'uk_UA.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'uk',
),
'en' => array(
'name' => 'English',
'locale' => 'en_US.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'en',
),
);
// Templates
define('ADMIN_TPL_DIR', TEMPLATES_DIR .'/admin/');
define('ADMIN_TPL_DIR', TEMPLATES_DIR . '/admin/');
$bb_cfg['templates'] = array(
// 'folder' => 'Name',
'default' => 'Стандартный',
'default' => 'Стандартный',
);
$bb_cfg['tpl_name'] = 'default';
$bb_cfg['tpl_name'] = 'default';
$bb_cfg['stylesheet'] = 'main.css';
$bb_cfg['show_sidebar1_on_every_page'] = false;
@ -341,11 +356,11 @@ $bb_cfg['show_sidebar2_on_every_page'] = false;
$page_cfg['show_sidebar1'] = array(
# BB_SCRIPT => true
'index' => true,
'index' => true,
);
$page_cfg['show_sidebar2'] = array(
# BB_SCRIPT => true
'index' => true,
'index' => true,
);
// Cookie
@ -354,167 +369,171 @@ $bb_cfg['cookie_secure'] = (!empty($_SERVER['HTTPS']) ? 1 : 0);
$bb_cfg['cookie_prefix'] = 'bb_'; // 'bb_'
// Sessions
$bb_cfg['session_update_intrv'] = 180; // sec
$bb_cfg['user_session_duration'] = 1800; // sec
$bb_cfg['admin_session_duration'] = 6*3600; // sec
$bb_cfg['user_session_gc_ttl'] = 1800; // number of seconds that a staled session entry may remain in sessions table
$bb_cfg['session_cache_gc_ttl'] = 1200; // sec
$bb_cfg['max_last_visit_days'] = 14; // days
$bb_cfg['session_update_intrv'] = 180; // sec
$bb_cfg['user_session_duration'] = 1800; // sec
$bb_cfg['admin_session_duration'] = 6 * 3600; // sec
$bb_cfg['user_session_gc_ttl'] = 1800; // number of seconds that a staled session entry may remain in sessions table
$bb_cfg['session_cache_gc_ttl'] = 1200; // sec
$bb_cfg['max_last_visit_days'] = 14; // days
$bb_cfg['last_visit_update_intrv'] = 3600; // sec
// Registration
$bb_cfg['invalid_logins'] = 5; // Количество неверных попыток ввода пароля, перед выводом проверки капчей
$bb_cfg['new_user_reg_disabled'] = false; // Запретить регистрацию новых учетных записей
$bb_cfg['unique_ip'] = false; // Запретить регистрацию нескольких учетных записей с одного ip
$bb_cfg['invalid_logins'] = 5; // Количество неверных попыток ввода пароля, перед выводом проверки капчей
$bb_cfg['new_user_reg_disabled'] = false; // Запретить регистрацию новых учетных записей
$bb_cfg['unique_ip'] = false; // Запретить регистрацию нескольких учетных записей с одного ip
$bb_cfg['new_user_reg_restricted'] = false; // Ограничить регистрацию новых пользователей по времени с 01:00 до 17:00
$bb_cfg['reg_email_activation'] = true; // Требовать активацию учетной записи по email
$bb_cfg['reg_email_activation'] = true; // Требовать активацию учетной записи по email
// Email
$bb_cfg['emailer_disabled'] = false;
$bb_cfg['emailer_disabled'] = false;
$bb_cfg['smtp_delivery'] = false; // send email via a named server instead of the local mail function
$bb_cfg['smtp_ssl'] = false; // use ssl connect
$bb_cfg['smtp_host'] = ''; // SMTP server host
$bb_cfg['smtp_port'] = 25; // SMTP server port
$bb_cfg['smtp_username'] = ''; // enter a username if your SMTP server requires it
$bb_cfg['smtp_password'] = ''; // enter a password if your SMTP server requires it
$bb_cfg['smtp_delivery'] = false; // send email via a named server instead of the local mail function
$bb_cfg['smtp_ssl'] = false; // use ssl connect
$bb_cfg['smtp_host'] = ''; // SMTP server host
$bb_cfg['smtp_port'] = 25; // SMTP server port
$bb_cfg['smtp_username'] = ''; // enter a username if your SMTP server requires it
$bb_cfg['smtp_password'] = ''; // enter a password if your SMTP server requires it
$bb_cfg['board_email'] = "noreply@$domain_name"; // admin email address
$bb_cfg['board_email_form'] = false; // can users send email to each other via board
$bb_cfg['board_email_sig'] = ''; // this text will be attached to all emails the board sends
$bb_cfg['board_email_sitename'] = $domain_name; // sitename used in all emails header
$bb_cfg['board_email'] = "noreply@$domain_name"; // admin email address
$bb_cfg['board_email_form'] = false; // can users send email to each other via board
$bb_cfg['board_email_sig'] = ''; // this text will be attached to all emails the board sends
$bb_cfg['board_email_sitename'] = $domain_name; // sitename used in all emails header
$bb_cfg['topic_notify_enabled'] = true;
$bb_cfg['pm_notify_enabled'] = true;
$bb_cfg['group_send_email'] = true;
$bb_cfg['email_change_disabled'] = false; // disable changing email by user
$bb_cfg['topic_notify_enabled'] = true;
$bb_cfg['pm_notify_enabled'] = true;
$bb_cfg['group_send_email'] = true;
$bb_cfg['email_change_disabled'] = false; // disable changing email by user
$bb_cfg['tech_admin_email'] = "admin@$domain_name"; // email for sending error reports
$bb_cfg['abuse_email'] = "abuse@$domain_name";
$bb_cfg['adv_email'] = "adv@$domain_name";
$bb_cfg['tech_admin_email'] = "admin@$domain_name"; // email for sending error reports
$bb_cfg['abuse_email'] = "abuse@$domain_name";
$bb_cfg['adv_email'] = "adv@$domain_name";
// Debug
define('DBG_LOG', false); // enable forum debug (off on production)
define('DBG_TRACKER', false); // enable tracker debug (off on production)
define('COOKIE_DBG', 'bb_dbg'); // debug cookie name
define('SQL_DEBUG', true); // enable forum sql & cache debug
define('SQL_LOG_ERRORS', true); // all SQL_xxx options enabled only if SQL_DEBUG == TRUE
define('SQL_CALC_QUERY_TIME', true); // for stats
define('DBG_LOG', false); // enable forum debug (off on production)
define('DBG_TRACKER', false); // enable tracker debug (off on production)
define('COOKIE_DBG', 'bb_dbg'); // debug cookie name
define('SQL_DEBUG', true); // enable forum sql & cache debug
define('SQL_LOG_ERRORS', true); // all SQL_xxx options enabled only if SQL_DEBUG == TRUE
define('SQL_CALC_QUERY_TIME', true); // for stats
define('SQL_LOG_SLOW_QUERIES', true); // log sql slow queries
define('SQL_SLOW_QUERY_TIME', 10); // slow query in seconds
define('SQL_SLOW_QUERY_TIME', 10); // slow query in seconds
define('SQL_PREPEND_SRC_COMM', false); // prepend source file comment to sql query
// Special users
$bb_cfg['dbg_users'] = array(
# user_id => 'name',
2 => 'admin',
2 => 'admin',
);
$bb_cfg['unlimited_users'] = array(
# user_id => 'name',
2 => 'admin',
2 => 'admin',
);
$bb_cfg['super_admins'] = array(
# user_id => 'name',
2 => 'admin',
2 => 'admin',
);
// Log options
define('LOG_EXT', 'log');
define('LOG_SEPR', ' | ');
define('LOG_LF', "\n");
define('LOG_EXT', 'log');
define('LOG_SEPR', ' | ');
define('LOG_LF', "\n");
define('LOG_MAX_SIZE', 1048576); // bytes
// Error reporting
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', LOG_DIR .'php_err.log');
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', LOG_DIR . 'php_err.log');
// Check some variable
// Magic quotes
if (get_magic_quotes_gpc()) die('Set magic_quotes off');
if (get_magic_quotes_gpc()) {
die('Set magic_quotes off');
}
// JSON
if (!function_exists('json_encode')) die('Json_encode not installed');
if (!function_exists('json_encode')) {
die('Json_encode not installed');
}
// Triggers
define('BB_ENABLED', TRIGGERS_DIR .'$on');
define('BB_DISABLED', TRIGGERS_DIR .'$off');
define('CRON_ALLOWED', TRIGGERS_DIR .'cron_allowed');
define('CRON_RUNNING', TRIGGERS_DIR .'cron_running');
define('BB_ENABLED', TRIGGERS_DIR . '$on');
define('BB_DISABLED', TRIGGERS_DIR . '$off');
define('CRON_ALLOWED', TRIGGERS_DIR . 'cron_allowed');
define('CRON_RUNNING', TRIGGERS_DIR . 'cron_running');
// Date format
$bb_cfg['date_format'] = 'Y-m-d';
$bb_cfg['date_format'] = 'Y-m-d';
// Subforums
$bb_cfg['sf_on_first_page_only'] = true;
$bb_cfg['sf_on_first_page_only'] = true;
// Forums
$bb_cfg['allowed_topics_per_page'] = array(50, 100, 150, 200, 250, 300);
// Topics
$bb_cfg['show_quick_reply'] = true;
$bb_cfg['show_rank_text'] = false;
$bb_cfg['show_rank_image'] = true;
$bb_cfg['show_poster_joined'] = true;
$bb_cfg['show_poster_posts'] = true;
$bb_cfg['show_poster_from'] = true;
$bb_cfg['show_bot_nick'] = false;
$bb_cfg['text_buttons'] = false; // replace EDIT, QUOTE... images with text links
$bb_cfg['parse_ed2k_links'] = true; // make ed2k links clickable
$bb_cfg['post_date_format'] = 'd-M-Y H:i';
$bb_cfg['ext_link_new_win'] = true; // open external links in new window
$bb_cfg['show_quick_reply'] = true;
$bb_cfg['show_rank_text'] = false;
$bb_cfg['show_rank_image'] = true;
$bb_cfg['show_poster_joined'] = true;
$bb_cfg['show_poster_posts'] = true;
$bb_cfg['show_poster_from'] = true;
$bb_cfg['show_bot_nick'] = false;
$bb_cfg['text_buttons'] = false; // replace EDIT, QUOTE... images with text links
$bb_cfg['parse_ed2k_links'] = true; // make ed2k links clickable
$bb_cfg['post_date_format'] = 'd-M-Y H:i';
$bb_cfg['ext_link_new_win'] = true; // open external links in new window
$bb_cfg['topic_moved_days_keep'] = 7; // remove topic moved links after xx days (or FALSE to disable)
$bb_cfg['topic_moved_days_keep'] = 7; // remove topic moved links after xx days (or FALSE to disable)
$bb_cfg['allowed_posts_per_page'] = array(15, 30, 50, 100);
$bb_cfg['user_signature_start'] = '<div class="signature"><br />_________________<br />';
$bb_cfg['user_signature_end'] = '</div>'; // Это позволит использовать html теги, которые требуют закрытия. Например <table> или <font color>
$bb_cfg['user_signature_start'] = '<div class="signature"><br />_________________<br />';
$bb_cfg['user_signature_end'] = '</div>'; // Это позволит использовать html теги, которые требуют закрытия. Например <table> или <font color>
// Posts
$bb_cfg['use_posts_cache'] = true; // if you switch from ON to OFF, you need to TRUNCATE `bb_posts_html` table
$bb_cfg['use_posts_cache'] = true; // if you switch from ON to OFF, you need to TRUNCATE `bb_posts_html` table
$bb_cfg['posts_cache_days_keep'] = 14;
$bb_cfg['max_post_length'] = 120000; // bytes
$bb_cfg['use_ajax_posts'] = true;
$bb_cfg['max_post_length'] = 120000; // bytes
$bb_cfg['use_ajax_posts'] = true;
// Search
$bb_cfg['search_engine_type'] = 'mysql'; // none, mysql, sphinx
$bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1';
$bb_cfg['sphinx_topic_titles_port'] = 3312;
$bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf");
$bb_cfg['search_engine_type'] = 'mysql'; // none, mysql, sphinx
$bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1';
$bb_cfg['sphinx_topic_titles_port'] = 3312;
$bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf");
$bb_cfg['disable_ft_search_in_posts'] = false; // disable searching in post bodies
$bb_cfg['disable_search_for_guest'] = true;
$bb_cfg['allow_search_in_bool_mode'] = true;
$bb_cfg['max_search_words_per_post'] = 200;
$bb_cfg['search_min_word_len'] = 3;
$bb_cfg['search_max_word_len'] = 35;
$bb_cfg['limit_max_search_results'] = false;
$bb_cfg['spam_filter_file_path'] = ''; // BB_PATH .'/misc/spam_filter_words.txt';
$bb_cfg['autocorrect_wkl'] = true; // autocorrect wrong keyboard layout
$bb_cfg['disable_search_for_guest'] = true;
$bb_cfg['allow_search_in_bool_mode'] = true;
$bb_cfg['max_search_words_per_post'] = 200;
$bb_cfg['search_min_word_len'] = 3;
$bb_cfg['search_max_word_len'] = 35;
$bb_cfg['limit_max_search_results'] = false;
$bb_cfg['spam_filter_file_path'] = ''; // BB_PATH .'/misc/spam_filter_words.txt';
$bb_cfg['autocorrect_wkl'] = true; // autocorrect wrong keyboard layout
// Posting
$bb_cfg['prevent_multiposting'] = true; // replace "reply" with "edit last msg" if user (not admin or mod) is last topic poster
$bb_cfg['max_smilies'] = 10; // Максимальное число смайлов в посте (0 - без ограничения)
$bb_cfg['prevent_multiposting'] = true; // replace "reply" with "edit last msg" if user (not admin or mod) is last topic poster
$bb_cfg['max_smilies'] = 10; // Максимальное число смайлов в посте (0 - без ограничения)
// PM
$bb_cfg['privmsg_disable'] = false; // отключить систему личных сообщений на форуме
$bb_cfg['max_outgoing_pm_cnt'] = 10; // ограничение на кол. одновременных исходящих лс (для замедления рассылки спама)
$bb_cfg['max_inbox_privmsgs'] = 200; // максимальное число сообщений в папке входящие
$bb_cfg['privmsg_disable'] = false; // отключить систему личных сообщений на форуме
$bb_cfg['max_outgoing_pm_cnt'] = 10; // ограничение на кол. одновременных исходящих лс (для замедления рассылки спама)
$bb_cfg['max_inbox_privmsgs'] = 200; // максимальное число сообщений в папке входящие
$bb_cfg['max_savebox_privmsgs'] = 25; // максимальное число сообщений в папке сохраненные
$bb_cfg['max_sentbox_privmsgs'] = 50; // максимальное число сообщений в папке отправленные
$bb_cfg['pm_days_keep'] = 180; // время хранения ЛС
$bb_cfg['pm_days_keep'] = 180; // время хранения ЛС
// Actions log
$bb_cfg['log_days_keep'] = 90;
// Users
$bb_cfg['color_nick'] = true; // Окраска ников пользователей по user_rank
$bb_cfg['color_nick'] = true; // Окраска ников пользователей по user_rank
$bb_cfg['user_not_activated_days_keep'] = 7; // "not activated" == "not finished registration"
$bb_cfg['user_not_active_days_keep'] = 180; // inactive users but only with no posts
$bb_cfg['user_not_active_days_keep'] = 180; // inactive users but only with no posts
// Groups
$bb_cfg['group_members_per_page'] = 50;
$bb_cfg['group_members_per_page'] = 50;
// Tidy
$bb_cfg['tidy_post'] = (!in_array('tidy', get_loaded_extensions())) ? false : true;
@ -523,17 +542,17 @@ $bb_cfg['tidy_post'] = (!in_array('tidy', get_loaded_extensions())) ? false : tr
$bb_cfg['show_ads'] = false;
$bb_cfg['show_ads_users'] = array(
# user_id => 'name',
2 => 'admin',
2 => 'admin',
);
// block_type => [block_id => block_desc]
$bb_cfg['ad_blocks'] = array(
'trans' => array(
100 => 'сквозная сверху',
),
'index' => array(
200 => 'главная, под новостями',
),
'trans' => array(
100 => 'сквозная сверху',
),
'index' => array(
200 => 'главная, под новостями',
),
);
// Misc
@ -545,12 +564,12 @@ $bb_cfg['translate_dates'] = true; // in displaying time
$bb_cfg['use_word_censor'] = true;
$bb_cfg['last_visit_date_format'] = 'd-M H:i';
$bb_cfg['last_post_date_format'] = 'd-M-y H:i';
$bb_cfg['poll_max_days'] = 180; // сколько дней с момента создания темы опрос будет активным
$bb_cfg['last_post_date_format'] = 'd-M-y H:i';
$bb_cfg['poll_max_days'] = 180; // сколько дней с момента создания темы опрос будет активным
$bb_cfg['allow_change'] = array(
'language' => true,
'dateformat' => true,
'language' => true,
'dateformat' => true,
);
define('GZIP_OUTPUT_ALLOWED', (extension_loaded('zlib') && !ini_get('zlib.output_compression')));
@ -568,27 +587,27 @@ $bb_cfg['trash_forum_id'] = 0; // (int) 7
$bb_cfg['first_logon_redirect_url'] = 'index.php';
$bb_cfg['terms_and_conditions_url'] = 'terms.php';
$bb_cfg['user_agreement_url'] = 'info.php?show=user_agreement';
$bb_cfg['copyright_holders_url'] = 'info.php?show=copyright_holders';
$bb_cfg['advert_url'] = 'info.php?show=advert';
$bb_cfg['user_agreement_url'] = 'info.php?show=user_agreement';
$bb_cfg['copyright_holders_url'] = 'info.php?show=copyright_holders';
$bb_cfg['advert_url'] = 'info.php?show=advert';
// Extensions
$bb_cfg['file_id_ext'] = array(
1 => 'gif',
2 => 'gz',
3 => 'jpg',
4 => 'png',
5 => 'rar',
6 => 'tar',
7 => 'tiff',
8 => 'torrent',
9 => 'zip',
1 => 'gif',
2 => 'gz',
3 => 'jpg',
4 => 'png',
5 => 'rar',
6 => 'tar',
7 => 'tiff',
8 => 'torrent',
9 => 'zip',
);
// Attachments
$bb_cfg['attach'] = array(
'upload_path' => DATA_DIR . 'torrent_files', // путь к директории с torrent файлами
'max_size' => 250*1024, // размер аватары в байтах
'upload_path' => DATA_DIR . 'torrent_files', // путь к директории с torrent файлами
'max_size' => 250 * 1024, // размер аватары в байтах
);
$bb_cfg['tor_forums_allowed_ext'] = array('torrent', 'zip', 'rar'); // для разделов с раздачами
@ -596,52 +615,51 @@ $bb_cfg['gen_forums_allowed_ext'] = array('zip', 'rar'); // для о
// Avatars
$bb_cfg['avatars'] = array(
'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов
'bot_avatar' => 'gallery/bot.gif', // аватара бота
'max_size' => 100*1024, // размер аватары в байтах
'max_height' => 100, // высота аватара в px
'max_width' => 100, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
'allowed_ext' => array('gif', 'jpg', 'jpeg', 'png'), // разрешенные форматы файлов
'bot_avatar' => 'gallery/bot.gif', // аватара бота
'max_size' => 100 * 1024, // размер аватары в байтах
'max_height' => 100, // высота аватара в px
'max_width' => 100, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
);
// Group avatars
$bb_cfg['group_avatars'] = array(
'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов
'max_size' => 300*1024, // размер аватары в байтах
'max_height' => 300, // высота аватара в px
'max_width' => 300, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
'allowed_ext' => array('gif', 'jpg', 'jpeg', 'png'), // разрешенные форматы файлов
'max_size' => 300 * 1024, // размер аватары в байтах
'max_height' => 300, // высота аватара в px
'max_width' => 300, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
);
// Captcha
// Get a Google reCAPTCHA API Key: https://www.google.com/recaptcha/admin
$bb_cfg['captcha'] = array(
'disabled' => false,
'public_key' => '', // your public key
'secret_key' => '', // your secret key
'theme' => 'light', // light or dark
'disabled' => false,
'public_key' => '', // your public key
'secret_key' => '', // your secret key
'theme' => 'light', // light or dark
);
// Atom feed
$bb_cfg['atom'] = array(
'path' => INT_DATA_DIR .'atom', // without ending slash
'url' => './internal_data/atom', // without ending slash
'path' => INT_DATA_DIR . 'atom', // without ending slash
'url' => './internal_data/atom', // without ending slash
);
// Nofollow
$bb_cfg['nofollow'] = array(
'disabled' => false,
'allowed_url' => array($domain_name), // 'allowed.site', 'www.allowed.site'
'disabled' => false,
'allowed_url' => array($domain_name), // 'allowed.site', 'www.allowed.site'
);
// Local config
if (file_exists(BB_ROOT. '/library/config.local.php'))
{
include_once(BB_ROOT. '/library/config.local.php');
if (file_exists(BB_ROOT . '/library/config.local.php')) {
include_once(BB_ROOT . '/library/config.local.php');
}
define('BB_CFG_LOADED', true);
define('BB_CFG_LOADED', true);

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more