Реформат в 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,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['ATTACHMENTS']['CONTROL_PANEL'] = basename(__FILE__);
return;
}
@ -9,20 +31,16 @@ require('./pagestart.php');
$total_attachments = 0;
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':')))
{
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':'))) {
$upload_dir = $attach_config['upload_dir'];
}
else
{
} else {
$upload_dir = '../' . $attach_config['upload_dir'];
}
include(ATTACH_DIR . 'includes/functions_selects.php');
// Check if the language got included
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL']))
{
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL'])) {
// include_once is used within the function
include_attach_lang();
}
@ -38,37 +56,28 @@ $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')
{
if ($view == 'username') {
$mode_types_text = array($lang['SORT_USERNAME'], $lang['SORT_ATTACHMENTS'], $lang['SORT_SIZE']);
$mode_types = array('username', 'attachments', 'filesize');
if (!$mode)
{
if (!$mode) {
$mode = 'attachments';
$sort_order = 'DESC';
}
}
else if ($view == 'attachments')
{
} 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)
{
if (!$mode) {
$mode = 'real_filename';
$sort_order = 'ASC';
}
}
else if ($view == 'search')
{
} 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
{
} else {
$view = 'stats';
$mode_types_text = array();
$sort_order = 'ASC';
@ -80,10 +89,8 @@ $do_pagination = ($view != 'stats' && $view != 'search') ? true : false;
// Set Order
$order_by = '';
if ($view == 'username')
{
switch($mode)
{
if ($view == 'username') {
switch ($mode) {
case 'username':
$order_by = 'ORDER BY u.username ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
@ -99,11 +106,8 @@ if ($view == 'username')
$order_by = 'ORDER BY total_attachments ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
}
}
else if ($view == 'attachments')
{
switch($mode)
{
} elseif ($view == 'attachments') {
switch ($mode) {
case 'filename':
$order_by = 'ORDER BY a.real_filename ' . $sort_order . ' LIMIT ' . $start . ', ' . $bb_cfg['topics_per_page'];
break;
@ -136,19 +140,16 @@ $view_types = array('stats', 'search');
$select_view = '<select name="view">';
for($i = 0; $i < count($view_types_text); $i++)
{
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)
{
if (count($mode_types_text) > 0) {
$select_sort_mode = '<select name="mode">';
for($i = 0; $i < count($mode_types_text); $i++)
{
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>';
}
@ -156,30 +157,24 @@ if (count($mode_types_text) > 0)
}
$select_sort_order = '<select name="order">';
if ($sort_order == 'ASC')
{
if ($sort_order == 'ASC') {
$select_sort_order .= '<option value="ASC" selected="selected">' . $lang['ASC'] . '</option><option value="DESC">' . $lang['DESC'] . '</option>';
}
else
{
} 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)
{
if ($confirm && sizeof($delete_id_list) > 0) {
$attachments = array();
delete_attachment(0, $delete_id_list);
}
else if ($delete && sizeof($delete_id_list) > 0)
{
} 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 . '" />';
@ -187,8 +182,7 @@ else if ($delete && sizeof($delete_id_list) > 0)
$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++)
{
for ($i = 0; $i < sizeof($delete_id_list); $i++) {
$hidden_fields .= '<input type="hidden" name="delete_id_list[]" value="' . $delete_id_list[$i] . '" />';
}
@ -204,8 +198,7 @@ $template->assign_vars(array(
'S_MODE_ACTION' => 'admin_attach_cp.php',
));
if ($submit_change && $view == 'attachments')
{
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));
@ -213,8 +206,7 @@ if ($submit_change && $view == 'attachments')
// Generate correct Change List
$attachments = array();
for ($i = 0; $i < count($attach_change_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];
}
@ -223,23 +215,18 @@ if ($submit_change && $view == 'attachments')
FROM ' . BB_ATTACHMENTS_DESC . '
ORDER BY attach_id';
if (!($result = DB()->sql_query($sql)))
{
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'])
{
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))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not update attachments informations');
}
}
@ -249,8 +236,7 @@ if ($submit_change && $view == 'attachments')
}
// Statistics
if ($view == 'stats')
{
if ($view == 'stats') {
$upload_dir_size = get_formatted_dirsize();
$attachment_quota = humn_size($attach_config['attachment_quota']);
@ -285,12 +271,10 @@ if ($view == 'stats')
'NUMBER_OF_TOPICS' => $number_of_topics,
'NUMBER_OF_USERS' => $number_of_users,
));
}
// Search
if ($view == '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
@ -298,36 +282,29 @@ if ($view == 'search')
WHERE f.cat_id = c.cat_id
ORDER BY c.cat_id, f.forum_order";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain forum_name / forum_id');
}
$s_forums = '';
while ($row = DB()->sql_fetchrow($result))
{ //sf
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']]) )
{
if (empty($list_cat[$row['cat_id']])) {
$list_cat[$row['cat_id']] = $row['cat_title'];
}
}
if( $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>';
foreach ($list_cat as $cat_id => $cat_title)
{
foreach ($list_cat as $cat_id => $cat_title) {
$s_categories .= '<option value="' . $cat_id . '">' . htmlCHR($cat_title) . '</option>';
}
}
else
{
} else {
bb_die($lang['NO_SEARCHABLE_FORUMS']);
}
@ -341,8 +318,7 @@ if ($view == 'search')
}
// Username
if ($view == 'username')
{
if ($view == 'username') {
$template->assign_vars(array(
'TPL_ATTACH_USER' => true,
'S_MODE_SELECT' => $select_sort_mode,
@ -353,10 +329,9 @@ if ($view == 'username')
}
// 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 = '';
@ -369,12 +344,10 @@ if ($view == 'attachments')
$total_rows = 0;
// Are we called from Username ?
if ($user_based)
{
if ($user_based) {
$sql = "SELECT username FROM " . BB_USERS . " WHERE user_id = " . intval($uid);
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Error getting username');
}
@ -396,8 +369,7 @@ if ($view == 'attachments')
WHERE user_id_1 = " . intval($uid) . "
GROUP BY attach_id";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #1');
}
@ -405,8 +377,7 @@ if ($view == 'attachments')
$num_attach_ids = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_attach_ids == 0)
{
if ($num_attach_ids == 0) {
bb_die('For some reason no attachments are assigned to the user ' . $username);
}
@ -414,8 +385,7 @@ if ($view == 'attachments')
$attach_id = array();
for ($j = 0; $j < $num_attach_ids; $j++)
{
for ($j = 0; $j < $num_attach_ids; $j++) {
$attach_id[] = intval($attach_ids[$j]['attach_id']);
}
@ -424,31 +394,24 @@ if ($view == 'attachments')
WHERE a.attach_id IN (" . implode(', ', $attach_id) . ") " .
$order_by;
if (!($result = DB()->sql_query($sql)))
{
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
{
} else {
// we are called from search
$attachments = search_attachments($order_by, $total_rows);
}
if (sizeof($attachments) > 0)
{
for ($i = 0; $i < sizeof($attachments); $i++)
{
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'])
{
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;
}
@ -464,8 +427,7 @@ if ($view == 'attachments')
FROM " . BB_ATTACHMENTS . "
WHERE attach_id = " . intval($attachments[$i]['attach_id']);
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #3');
}
@ -473,17 +435,14 @@ if ($view == 'attachments')
$num_ids = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($j = 0; $j < $num_ids; $j++)
{
if ($ids[$j]['post_id'] != 0)
{
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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query topic');
}
@ -491,17 +450,14 @@ if ($view == 'attachments')
DB()->sql_freeresult($result);
$post_title = $row['topic_title'];
if (strlen($post_title) > 32)
{
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'];
$post_titles[] = '<a href="' . $view_topic . '" class="gen" target="_blank">' . $post_title . '</a>';
}
else
{
} else {
$post_titles[] = $lang['PRIVATE_MESSAGE'];
}
}
@ -526,18 +482,14 @@ if ($view == 'attachments')
'S_HIDDEN' => $hidden_field,
'U_VIEW_ATTACHMENT' => BB_ROOT . DOWNLOAD_URL . $attachments[$i]['attach_id'],
));
}
}
if (!$search_based && !$user_based)
{
if ($total_attachments == 0)
{
if (!$search_based && !$user_based) {
if ($total_attachments == 0) {
$sql = "SELECT attach_id FROM " . BB_ATTACHMENTS_DESC;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachment description table');
}
@ -548,8 +500,7 @@ if ($view == 'attachments')
}
// Generate Pagination
if ($do_pagination && $total_rows > $bb_cfg['topics_per_page'])
{
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;';
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$filename = basename(__FILE__);
$module['ATTACHMENTS']['MANAGE'] = $filename . '?mode=manage';
$module['ATTACHMENTS']['SPECIAL_CATEGORIES'] = $filename . '?mode=cats';
@ -12,20 +34,16 @@ require('./pagestart.php');
$error = false;
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':')))
{
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':'))) {
$upload_dir = $attach_config['upload_dir'];
}
else
{
} else {
$upload_dir = '../' . $attach_config['upload_dir'];
}
include(ATTACH_DIR . 'includes/functions_selects.php');
// Check if the language got included
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL']))
{
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL'])) {
// include_once is used within the function
include_attach_lang();
}
@ -37,110 +55,89 @@ $size = request_var('size', '');
$quota_size = request_var('quota_size', '');
$pm_size = request_var('pm_size', '');
$submit = (isset($_POST['submit'])) ? TRUE : FALSE;
$check_upload = (isset($_POST['settings'])) ? TRUE : FALSE;
$check_image_cat = (isset($_POST['cat_settings'])) ? TRUE : FALSE;
$search_imagick = (isset($_POST['search_imagick'])) ? TRUE : FALSE;
$submit = (isset($_POST['submit'])) ? true : false;
$check_upload = (isset($_POST['settings'])) ? true : false;
$check_image_cat = (isset($_POST['cat_settings'])) ? true : false;
$search_imagick = (isset($_POST['search_imagick'])) ? true : false;
// Re-evaluate the Attachment Configuration
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not find attachment config table #1');
}
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$new_attach[$config_name] = get_var($config_name, trim($attach_config[$config_name]));
if (!$size && !$submit && $config_name == 'max_filesize')
{
if (!$size && !$submit && $config_name == 'max_filesize') {
$size = ($attach_config[$config_name] >= 1048576) ? 'mb' : (($attach_config[$config_name] >= 1024) ? 'kb' : 'b');
}
if (!$quota_size && !$submit && $config_name == 'attachment_quota')
{
if (!$quota_size && !$submit && $config_name == 'attachment_quota') {
$quota_size = ($attach_config[$config_name] >= 1048576) ? 'mb' : (($attach_config[$config_name] >= 1024) ? 'kb' : 'b');
}
if (!$pm_size && !$submit && $config_name == 'max_filesize_pm')
{
if (!$pm_size && !$submit && $config_name == 'max_filesize_pm') {
$pm_size = ($attach_config[$config_name] >= 1048576) ? 'mb' : (($attach_config[$config_name] >= 1024) ? 'kb' : 'b');
}
if (!$submit && ($config_name == 'max_filesize' || $config_name == 'attachment_quota' || $config_name == 'max_filesize_pm'))
{
if ($new_attach[$config_name] >= 1048576)
{
if (!$submit && ($config_name == 'max_filesize' || $config_name == 'attachment_quota' || $config_name == 'max_filesize_pm')) {
if ($new_attach[$config_name] >= 1048576) {
$new_attach[$config_name] = round($new_attach[$config_name] / 1048576 * 100) / 100;
}
else if ($new_attach[$config_name] >= 1024)
{
} elseif ($new_attach[$config_name] >= 1024) {
$new_attach[$config_name] = round($new_attach[$config_name] / 1024 * 100) / 100;
}
}
if ( $submit && ( $mode == 'manage' || $mode == 'cats') )
{
if ($config_name == 'max_filesize')
{
if ($submit && ($mode == 'manage' || $mode == 'cats')) {
if ($config_name == 'max_filesize') {
$old = $new_attach[$config_name];
$new_attach[$config_name] = ($size == 'kb') ? round($new_attach[$config_name] * 1024) : (($size == 'mb') ? round($new_attach[$config_name] * 1048576) : $new_attach[$config_name]);
}
if ($config_name == 'attachment_quota')
{
if ($config_name == 'attachment_quota') {
$old = $new_attach[$config_name];
$new_attach[$config_name] = ($quota_size == 'kb') ? round($new_attach[$config_name] * 1024) : (($quota_size == 'mb') ? round($new_attach[$config_name] * 1048576) : $new_attach[$config_name]);
}
if ($config_name == 'max_filesize_pm')
{
if ($config_name == 'max_filesize_pm') {
$old = $new_attach[$config_name];
$new_attach[$config_name] = ($pm_size == 'kb') ? round($new_attach[$config_name] * 1024) : (($pm_size == 'mb') ? round($new_attach[$config_name] * 1048576) : $new_attach[$config_name]);
}
if ($config_name == 'max_filesize')
{
if ($config_name == 'max_filesize') {
$old_size = $attach_config[$config_name];
$new_size = $new_attach[$config_name];
if ($old_size != $new_size)
{
if ($old_size != $new_size) {
// See, if we have a similar value of old_size in Mime Groups. If so, update these values.
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . '
SET max_filesize = ' . (int)$new_size . '
WHERE max_filesize = ' . (int)$old_size;
if (!($result_2 = DB()->sql_query($sql)))
{
if (!($result_2 = DB()->sql_query($sql))) {
bb_die('Could not update extension group information');
}
}
$sql = "UPDATE " . BB_ATTACH_CONFIG . "
SET config_value = '" . attach_mod_sql_escape($new_attach[$config_name]) . "'
WHERE config_name = '" . attach_mod_sql_escape($config_name) . "'";
}
else
{
} else {
$sql = "UPDATE " . BB_ATTACH_CONFIG . "
SET config_value = '" . attach_mod_sql_escape($new_attach[$config_name]) . "'
WHERE config_name = '" . attach_mod_sql_escape($config_name) . "'";
}
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die('Failed to update attachment configuration for ' . $config_name);
}
if ($config_name == 'max_filesize' || $config_name == 'attachment_quota' || $config_name == 'max_filesize_pm')
{
if ($config_name == 'max_filesize' || $config_name == 'attachment_quota' || $config_name == 'max_filesize_pm') {
$new_attach[$config_name] = $old;
}
}
@ -155,65 +152,49 @@ $select_quota_size_mode = size_select('quota_size', $quota_size);
$select_pm_size_mode = size_select('pm_size', $pm_size);
// Search Imagick
if ($search_imagick)
{
if ($search_imagick) {
$imagick = '';
if (preg_match('/convert/i', $imagick))
{
if (preg_match('/convert/i', $imagick)) {
return true;
}
else if ($imagick != 'none')
{
if (!preg_match('/WIN/i', PHP_OS))
{
} elseif ($imagick != 'none') {
if (!preg_match('/WIN/i', PHP_OS)) {
$retval = @exec('whereis convert');
$paths = explode(' ', $retval);
if (is_array($paths))
{
for ( $i=0; $i < sizeof($paths); $i++)
{
if (is_array($paths)) {
for ($i = 0; $i < sizeof($paths); $i++) {
$path = basename($paths[$i]);
if ($path == 'convert')
{
if ($path == 'convert') {
$imagick = $paths[$i];
}
}
}
}
else if (preg_match('/WIN/i', PHP_OS))
{
} elseif (preg_match('/WIN/i', PHP_OS)) {
$path = 'c:/imagemagick/convert.exe';
if ( !@file_exists(@amod_realpath($path)))
{
if (!@file_exists(@amod_realpath($path))) {
$imagick = $path;
}
}
}
if ( !@file_exists(@amod_realpath(trim($imagick))))
{
if (!@file_exists(@amod_realpath(trim($imagick)))) {
$new_attach['img_imagick'] = trim($imagick);
}
else
{
} else {
$new_attach['img_imagick'] = '';
}
}
// Check Settings
if ($check_upload)
{
if ($check_upload) {
// Some tests...
$attach_config = array();
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not find attachment config table #2');
}
@ -221,70 +202,55 @@ if ($check_upload)
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < $num_rows; $i++)
{
for ($i = 0; $i < $num_rows; $i++) {
$attach_config[$row[$i]['config_name']] = trim($row[$i]['config_value']);
}
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
$upload_dir = $attach_config['upload_dir'];
}
else
{
} else {
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
}
$error = false;
// Does the target directory exist, is it a directory and writeable
if ( !@file_exists(@amod_realpath($upload_dir)) )
{
if (!@file_exists(@amod_realpath($upload_dir))) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_DOES_NOT_EXIST'], $attach_config['upload_dir']) . '<br />';
}
if (!$error && !is_dir($upload_dir))
{
$error = TRUE;
if (!$error && !is_dir($upload_dir)) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_IS_NOT_A_DIR'], $attach_config['upload_dir']) . '<br />';
}
if (!$error)
{
if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'w')) )
{
$error = TRUE;
if (!$error) {
if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $attach_config['upload_dir']) . '<br />';
}
else
{
} else {
@fclose($fp);
unlink_attach($upload_dir . '/0_000000.000');
}
}
if (!$error)
{
if (!$error) {
bb_die($lang['TEST_SETTINGS_SUCCESSFUL'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '<a href="admin_attachments.php?mode=manage">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
// Management
if ($submit && $mode == 'manage')
{
if (!$error)
{
if ($submit && $mode == 'manage') {
if (!$error) {
bb_die($lang['ATTACH_CONFIG_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '<a href="admin_attachments.php?mode=manage">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
if ($mode == 'manage')
{
if ($mode == 'manage') {
$yes_no_switches = array('disable_mod', 'allow_pm_attach', 'display_order');
for ($i = 0; $i < sizeof($yes_no_switches); $i++)
{
for ($i = 0; $i < sizeof($yes_no_switches); $i++) {
eval("\$" . $yes_no_switches[$i] . "_yes = ( \$new_attach['" . $yes_no_switches[$i] . "'] != '0' ) ? 'checked=\"checked\"' : '';");
eval("\$" . $yes_no_switches[$i] . "_no = ( \$new_attach['" . $yes_no_switches[$i] . "'] == '0' ) ? 'checked=\"checked\"' : '';");
}
@ -315,34 +281,28 @@ if ($mode == 'manage')
));
}
if ($submit && $mode == 'cats')
{
if (!$error)
{
if ($submit && $mode == 'cats') {
if (!$error) {
bb_die($lang['ATTACH_CONFIG_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '<a href="admin_attachments.php?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
if ($mode == 'cats')
{
if ($mode == 'cats') {
$s_assigned_group_images = $lang['NONE'];
$sql = 'SELECT group_name, cat_id FROM ' . BB_EXTENSION_GROUPS . ' WHERE cat_id > 0 ORDER BY cat_id';
$s_assigned_group_images = array();
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get group names from ' . BB_EXTENSION_GROUPS);
}
$row = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($row); $i++)
{
if ($row[$i]['cat_id'] == IMAGE_CAT)
{
for ($i = 0; $i < sizeof($row); $i++) {
if ($row[$i]['cat_id'] == IMAGE_CAT) {
$s_assigned_group_images[] = $row[$i]['group_name'];
}
}
@ -357,12 +317,9 @@ if ($mode == 'cats')
$use_gd2_no = ($new_attach['use_gd2'] == '0') ? 'checked="checked"' : '';
// Check Thumbnail Support
if (!is_imagick() && !@extension_loaded('gd'))
{
if (!is_imagick() && !@extension_loaded('gd')) {
$new_attach['img_create_thumbnail'] = '0';
}
else
{
} else {
$template->assign_block_vars('switch_thumbnail_support', array());
}
@ -386,15 +343,13 @@ if ($mode == 'cats')
}
// Check Cat Settings
if ($check_image_cat)
{
if ($check_image_cat) {
// Some tests...
$attach_config = array();
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not find attachment config table #3');
}
@ -402,17 +357,13 @@ if ($check_image_cat)
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < $num_rows; $i++)
{
for ($i = 0; $i < $num_rows; $i++) {
$attach_config[$row[$i]['config_name']] = trim($row[$i]['config_value']);
}
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
$upload_dir = $attach_config['upload_dir'];
}
else
{
} else {
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
}
@ -421,47 +372,38 @@ if ($check_image_cat)
$error = false;
// Does the target directory exist, is it a directory and writeable
if ( !@file_exists(@amod_realpath($upload_dir)) )
{
if (!@file_exists(@amod_realpath($upload_dir))) {
@mkdir($upload_dir, 0755);
@chmod($upload_dir, 0777);
if ( !@file_exists(@amod_realpath($upload_dir)) )
{
$error = TRUE;
if (!@file_exists(@amod_realpath($upload_dir))) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_DOES_NOT_EXIST'], $upload_dir) . '<br />';
}
}
if (!$error && !is_dir($upload_dir))
{
$error = TRUE;
if (!$error && !is_dir($upload_dir)) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_IS_NOT_A_DIR'], $upload_dir) . '<br />';
}
if (!$error)
{
if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'w')) )
{
$error = TRUE;
if (!$error) {
if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) {
$error = true;
$error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $upload_dir) . '<br />';
}
else
{
} else {
@fclose($fp);
@unlink($upload_dir . '/0_000000.000');
}
}
if (!$error)
{
if (!$error) {
bb_die($lang['TEST_SETTINGS_SUCCESSFUL'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '<a href="admin_attachments.php?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
// Quota Limit Settings
if ($submit && $mode == 'quota')
{
if ($submit && $mode == 'quota') {
// Change Quota Limit
$quota_change_list = get_var('quota_change_list', array(0));
$quota_desc_list = get_var('quota_desc_list', array(''));
@ -470,16 +412,14 @@ if ($submit && $mode == 'quota')
$allowed_list = array();
for ($i = 0; $i < sizeof($quota_change_list); $i++)
{
for ($i = 0; $i < sizeof($quota_change_list); $i++) {
$filesize_list[$i] = ($size_select_list[$i] == 'kb') ? round($filesize_list[$i] * 1024) : (($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i]);
$sql = 'UPDATE ' . BB_QUOTA_LIMITS . "
SET quota_desc = '" . attach_mod_sql_escape($quota_desc_list[$i]) . "', quota_limit = " . (int)$filesize_list[$i] . "
WHERE quota_limit_id = " . (int)$quota_change_list[$i];
if (!(DB()->sql_query($sql)))
{
if (!(DB()->sql_query($sql))) {
bb_die('Could not update quota limits');
}
}
@ -489,20 +429,17 @@ if ($submit && $mode == 'quota')
$quota_id_sql = implode(', ', $quota_id_list);
if ($quota_id_sql != '')
{
if ($quota_id_sql != '') {
$sql = 'DELETE FROM ' . BB_QUOTA_LIMITS . ' WHERE quota_limit_id IN (' . $quota_id_sql . ')';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not delete quota limits');
}
// Delete Quotas linked to this setting
$sql = 'DELETE FROM ' . BB_QUOTA . ' WHERE quota_limit_id IN (' . $quota_id_sql . ')';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not delete quotas');
}
}
@ -511,15 +448,13 @@ if ($submit && $mode == 'quota')
$quota_desc = get_var('quota_description', '');
$filesize = get_var('add_max_filesize', 0);
$size_select = get_var('add_size_select', '');
$add = ( isset($_POST['add_quota_check']) ) ? TRUE : FALSE;
$add = (isset($_POST['add_quota_check'])) ? true : false;
if ($quota_desc != '' && $add)
{
if ($quota_desc != '' && $add) {
// check Quota Description
$sql = 'SELECT quota_desc FROM ' . BB_QUOTA_LIMITS;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query quota limits table');
}
@ -527,15 +462,11 @@ if ($submit && $mode == 'quota')
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ( $num_rows > 0 )
{
for ($i = 0; $i < $num_rows; $i++)
{
if ($row[$i]['quota_desc'] == $quota_desc)
{
$error = TRUE;
if( isset($error_msg) )
{
if ($num_rows > 0) {
for ($i = 0; $i < $num_rows; $i++) {
if ($row[$i]['quota_desc'] == $quota_desc) {
$error = true;
if (isset($error_msg)) {
$error_msg .= '<br />';
}
$error_msg .= sprintf($lang['QUOTA_LIMIT_EXIST'], $extension_group);
@ -543,39 +474,30 @@ if ($submit && $mode == 'quota')
}
}
if (!$error)
{
if (!$error) {
$filesize = ($size_select == 'kb') ? round($filesize * 1024) : (($size_select == 'mb') ? round($filesize * 1048576) : $filesize);
$sql = "INSERT INTO " . BB_QUOTA_LIMITS . " (quota_desc, quota_limit)
VALUES ('" . attach_mod_sql_escape($quota_desc) . "', " . (int)$filesize . ")";
if (!(DB()->sql_query($sql)))
{
if (!(DB()->sql_query($sql))) {
bb_die('Could not add quota limit');
}
}
}
if (!$error)
{
if (!$error) {
bb_die($lang['ATTACH_CONFIG_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '<a href="admin_attachments.php?mode=quota">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
if ($mode == 'quota')
{
if ($mode == 'quota') {
$max_add_filesize = $attach_config['max_filesize'];
$size = ($max_add_filesize >= 1048576) ? 'mb' : (($max_add_filesize >= 1024) ? 'kb' : 'b');
if ($max_add_filesize >= 1048576)
{
if ($max_add_filesize >= 1048576) {
$max_add_filesize = round($max_add_filesize / 1048576 * 100) / 100;
}
else if ( $max_add_filesize >= 1024)
{
} elseif ($max_add_filesize >= 1024) {
$max_add_filesize = round($max_add_filesize / 1024 * 100) / 100;
}
@ -588,24 +510,19 @@ if ($mode == 'quota')
$sql = "SELECT * FROM " . BB_QUOTA_LIMITS . " ORDER BY quota_limit DESC";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get quota limits #1');
}
$rows = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($rows); $i++)
{
for ($i = 0; $i < sizeof($rows); $i++) {
$size_format = ($rows[$i]['quota_limit'] >= 1048576) ? 'mb' : (($rows[$i]['quota_limit'] >= 1024) ? 'kb' : 'b');
if ( $rows[$i]['quota_limit'] >= 1048576)
{
if ($rows[$i]['quota_limit'] >= 1048576) {
$rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1048576 * 100) / 100;
}
else if($rows[$i]['quota_limit'] >= 1024)
{
} elseif ($rows[$i]['quota_limit'] >= 1024) {
$rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1024 * 100) / 100;
}
@ -619,12 +536,10 @@ if ($mode == 'quota')
}
}
if ($mode == 'quota' && $e_mode == 'view_quota')
{
if ($mode == 'quota' && $e_mode == 'view_quota') {
$quota_id = get_var('quota_id', 0);
if (!$quota_id)
{
if (!$quota_id) {
bb_die('Invalid call');
}
@ -632,8 +547,7 @@ if ($mode == 'quota' && $e_mode == 'view_quota')
$sql = "SELECT * FROM " . BB_QUOTA_LIMITS . " WHERE quota_limit_id = " . (int)$quota_id . " LIMIT 1";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get quota limits #2');
}
@ -650,8 +564,7 @@ if ($mode == 'quota' && $e_mode == 'view_quota')
AND q.user_id <> 0
AND q.user_id = u.user_id';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get quota limits #3');
}
@ -659,17 +572,13 @@ if ($mode == 'quota' && $e_mode == 'view_quota')
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < $num_rows; $i++)
{
if ($rows[$i]['quota_type'] == QUOTA_UPLOAD_LIMIT)
{
for ($i = 0; $i < $num_rows; $i++) {
if ($rows[$i]['quota_type'] == QUOTA_UPLOAD_LIMIT) {
$template->assign_block_vars('users_upload_row', array(
'USER_ID' => $rows[$i]['user_id'],
'USERNAME' => $rows[$i]['username'],
));
}
else if ($rows[$i]['quota_type'] == QUOTA_PM_LIMIT)
{
} elseif ($rows[$i]['quota_type'] == QUOTA_PM_LIMIT) {
$template->assign_block_vars('users_pm_row', array(
'USER_ID' => $rows[$i]['user_id'],
'USERNAME' => $rows[$i]['username'],
@ -683,8 +592,7 @@ if ($mode == 'quota' && $e_mode == 'view_quota')
AND q.group_id <> 0
AND q.group_id = g.group_id';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get quota limits #4');
}
@ -692,17 +600,13 @@ if ($mode == 'quota' && $e_mode == 'view_quota')
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < $num_rows; $i++)
{
if ($rows[$i]['quota_type'] == QUOTA_UPLOAD_LIMIT)
{
for ($i = 0; $i < $num_rows; $i++) {
if ($rows[$i]['quota_type'] == QUOTA_UPLOAD_LIMIT) {
$template->assign_block_vars('groups_upload_row', array(
'GROUP_ID' => $rows[$i]['group_id'],
'GROUPNAME' => $rows[$i]['group_name'],
));
}
else if ($rows[$i]['quota_type'] == QUOTA_PM_LIMIT)
{
} elseif ($rows[$i]['quota_type'] == QUOTA_PM_LIMIT) {
$template->assign_block_vars('groups_pm_row', array(
'GROUP_ID' => $rows[$i]['group_id'],
'GROUPNAME' => $rows[$i]['group_name'],
@ -711,8 +615,7 @@ if ($mode == 'quota' && $e_mode == 'view_quota')
}
}
if ($error)
{
if ($error) {
$template->assign_vars(array('ERROR_MESSAGE' => $error_msg));
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['GENERAL']['CONFIGURATION'] = basename(__FILE__) . '?mode=config';
$module['MODS']['CONFIGURATION'] = basename(__FILE__) . '?mode=config_mods';
return;
@ -22,35 +44,30 @@ $return_links = array(
// Pull all config data
//
$sql = "SELECT * FROM " . BB_CONFIG;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query config information in admin_board');
}
else
{
while ($row = DB()->sql_fetchrow($result))
{
} 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];
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]));
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']))
{
if (isset($_POST['submit'])) {
bb_die($lang['CONFIG_UPDATED'] . $return_links[$mode] . $return_links['index']);
}
}
switch ($mode)
{
switch ($mode) {
case 'config_mods':
$template->assign_vars(array(
'S_CONFIG_ACTION' => 'admin_board.php?mode=config_mods',
@ -82,14 +99,14 @@ switch ($mode)
'SEED_BONUS_USER_REGDATE' => $new['seed_bonus_user_regdate'],
));
if ($new['seed_bonus_points'] && $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],
@ -98,14 +115,14 @@ switch ($mode)
}
}
if ($new['bonus_upload'] && $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,

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['TP']['FORUM_CONFIG'] = basename(__FILE__);
return;
}
@ -64,10 +86,8 @@ $db_fields_bool = array(
$cfg = bb_get_config(BB_CONFIG, true, false);
// Submit new config
if ($submit && $confirm)
{
foreach ($db_fields_bool as $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);
}
@ -98,23 +118,19 @@ $sql = "SELECT f.*
WHERE f.cat_id = c.cat_id
ORDER BY c.cat_order, f.forum_order";
if (!$result = DB()->sql_query($sql))
{
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)
{
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)
{
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"' : '';
@ -124,8 +140,7 @@ foreach ($rowset as $rid => $forum)
}
}
foreach ($db_fields_bool as $field_name => $field_def_val)
{
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));
}

View file

@ -1,13 +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 (!empty($setmodules))
{
if (IS_SUPER_ADMIN) $module['TP']['TRACKER_CONFIG'] = basename(__FILE__);
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');

View file

@ -1,8 +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))
{
if (IS_SUPER_ADMIN) $module['TP']['CRON'] = basename(__FILE__) . '?mode=list';
if (!empty($setmodules)) {
if (IS_SUPER_ADMIN) {
$module['TP']['CRON'] = basename(__FILE__) . '?mode=list';
}
return;
}
@ -12,32 +36,32 @@ $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)
{
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');
$sql = DB()->fetch_rowset("SELECT * FROM " . BB_CONFIG . " WHERE config_name = 'cron_enabled' OR config_name = 'cron_check_interval'");
foreach ($sql as $row)
{
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];
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name])
{
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
bb_update_config(array($config_name => $new[$config_name]));
}
}
@ -47,13 +71,11 @@ $template->assign_vars(array(
'CRON_CHECK_INTERVAL' => $new['cron_check_interval'],
));
switch ($mode)
{
switch ($mode) {
case 'list':
$sql = DB()->fetch_rowset("SELECT * FROM " . BB_CRON . " ORDER BY cron_id");
foreach ($sql as $i => $row)
{
foreach ($sql as $i => $row) {
$template->assign_block_vars('list', array(
'ROW_CLASS' => !($i % 2) ? 'row2' : 'row1',
'JOB_ID' => $i + 1,
@ -76,8 +98,7 @@ switch ($mode)
));
//detect cron status
if (@file_exists('../triggers/cron_running'))
{
if (@file_exists('../triggers/cron_running')) {
$template->assign_vars(array(
'CRON_RUNNING' => true,
));
@ -85,8 +106,7 @@ switch ($mode)
break;
case 'repair':
if (@file_exists('../triggers/cron_running'))
{
if (@file_exists('../triggers/cron_running')) {
rename("../triggers/cron_running", "../triggers/cron_allowed");
}
redirect('admin/' . basename(__FILE__) . '?mode=list');
@ -100,8 +120,7 @@ switch ($mode)
case 'edit':
$sql = DB()->fetch_rowset("SELECT * FROM " . BB_CRON . " WHERE cron_id = $job_id");
foreach ($sql as $row)
{
foreach ($sql as $row) {
$template->assign_vars(array(
'CRON_ID' => $row['cron_id'],
'CRON_ACTIVE' => $row['cron_active'],
@ -123,14 +142,12 @@ switch ($mode)
}
$run_day = array($lang['DELTA_TIME']['INTERVALS']['mday'][0] => 0);
for ($i = 1; $i <= 28; $i++)
{
for ($i = 1; $i <= 28; $i++) {
$run_day[$i] = $i;
}
$schedule = array($lang['SCHEDULE']['select'] => 0);
foreach ($lang['SCHEDULE'] as $type => $key)
{
foreach ($lang['SCHEDULE'] as $type => $key) {
$schedule[$key] = $type;
}
@ -146,14 +163,12 @@ switch ($mode)
case 'add':
$run_day = array($lang['DELTA_TIME']['INTERVALS']['mday'][0] => 0);
for ($i = 1; $i <= 28; $i++)
{
for ($i = 1; $i <= 28; $i++) {
$run_day[$i] = $i;
}
$schedule = array();
foreach ($lang['SCHEDULE'] as $type => $key)
{
foreach ($lang['SCHEDULE'] as $type => $key) {
$schedule[$key] = $type;
}
@ -187,40 +202,27 @@ switch ($mode)
break;
}
if ($submit)
{
if ($_POST['mode'] == 'list')
{
if ($cron_action == 'run' && $jobs)
{
if ($submit) {
if ($_POST['mode'] == 'list') {
if ($cron_action == 'run' && $jobs) {
run_jobs($jobs);
}
else if ($cron_action == 'delete' && $jobs)
{
} elseif ($cron_action == 'delete' && $jobs) {
delete_jobs($jobs);
}
else if (($cron_action == 'disable' || $cron_action == 'enable') && $jobs)
{
} elseif (($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')
{
} elseif (validate_cron_post($_POST) == 1) {
if ($_POST['mode'] == 'edit') {
update_cron_job($_POST);
}
else if ($_POST['mode'] == 'add')
{
} elseif ($_POST['mode'] == 'add') {
insert_cron_job($_POST);
} else {
bb_die('Mode error');
}
else bb_die('Mode error');
redirect('admin/' . basename(__FILE__) . '?mode=list');
}
else
{
} else {
bb_die(validate_cron_post($_POST));
}
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['USERS']['DISALLOW'] = basename(__FILE__);
return;
}
@ -9,26 +31,20 @@ require('./pagestart.php');
$message = '';
if (isset($_POST['add_name']))
{
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']);
if ($disallowed_user == '')
{
if ($disallowed_user == '') {
bb_die($lang['FIELDS_EMPTY']);
}
if( !validate_username($disallowed_user) )
{
if (!validate_username($disallowed_user)) {
$message = $lang['DISALLOWED_ALREADY'];
}
else
{
} else {
$sql = "INSERT INTO " . BB_DISALLOW . " (disallow_username) VALUES('" . DB()->escape($disallowed_user) . "')";
$result = DB()->sql_query($sql);
if (!$result)
{
if (!$result) {
bb_die('Could not add disallowed user');
}
$message = $lang['DISALLOW_SUCCESSFUL'];
@ -37,22 +53,18 @@ if (isset($_POST['add_name']))
$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']))
{
} 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)
{
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);
}
//
@ -60,8 +72,7 @@ elseif (isset($_POST['delete_name']))
//
$sql = "SELECT * FROM " . BB_DISALLOW;
$result = DB()->sql_query($sql);
if (!$result)
{
if (!$result) {
bb_die('Could not get disallowed users');
}
@ -73,14 +84,10 @@ $disallowed = DB()->sql_fetchrowset($result);
//
$disallow_select = '<select name="disallowed_id">';
if (count($disallowed) <= 0)
{
if (count($disallowed) <= 0) {
$disallow_select .= '<option value="">' . $lang['NO_DISALLOWED'] . '</option>';
}
else
{
for ($i = 0; $i < count($disallowed); $i++)
{
} else {
for ($i = 0; $i < count($disallowed); $i++) {
$disallow_select .= '<option value="' . $disallowed[$i]['disallow_id'] . '">' . $disallowed[$i]['disallow_username'] . '</option>';
}
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$filename = basename(__FILE__);
$module['ATTACHMENTS']['EXTENSION_CONTROL'] = $filename . '?mode=extensions';
$module['ATTACHMENTS']['EXTENSION_GROUP_MANAGE'] = $filename . '?mode=groups';
@ -9,25 +31,23 @@ if (!empty($setmodules))
}
require('./pagestart.php');
function update_attach_extensions () {
function update_attach_extensions()
{
$GLOBALS['datastore']->update('attach_extensions');
}
register_shutdown_function('update_attach_extensions');
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':')))
{
if (($attach_config['upload_dir'][0] == '/') || (($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':'))) {
$upload_dir = $attach_config['upload_dir'];
}
else
{
} else {
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
}
include(ATTACH_DIR . 'includes/functions_selects.php');
// Check if the language got included
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL']))
{
if (!isset($lang['TEST_SETTINGS_SUCCESSFUL'])) {
// include_once is used within the function
include_attach_lang();
}
@ -43,27 +63,24 @@ $size = get_var('size', '');
$mode = get_var('mode', '');
$e_mode = get_var('e_mode', '');
$submit = (isset($_POST['submit'])) ? TRUE : FALSE;
$submit = (isset($_POST['submit'])) ? true : false;
// Get Attachment Config
$attach_config = array();
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachment information');
}
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$attach_config[$row['config_name']] = trim($row['config_value']);
}
DB()->sql_freeresult($result);
// Extension Management
if ($submit && $mode == 'extensions')
{
if ($submit && $mode == 'extensions') {
// Change Extensions ?
$extension_change_list = get_var('extension_change_list', array(0));
$extension_explain_list = get_var('extension_explain_list', array(''));
@ -72,15 +89,13 @@ if ($submit && $mode == 'extensions')
// Generate correct Change List
$extensions = array();
for ($i = 0; $i < sizeof($extension_change_list); $i++)
{
for ($i = 0; $i < sizeof($extension_change_list); $i++) {
$extensions['_' . $extension_change_list[$i]]['comment'] = $extension_explain_list[$i];
$extensions['_' . $extension_change_list[$i]]['group_id'] = intval($group_select_list[$i]);
}
$sql = 'SELECT * FROM ' . BB_EXTENSIONS . ' ORDER BY ext_id';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get extension informations #1');
}
@ -88,12 +103,9 @@ if ($submit && $mode == 'extensions')
$extension_row = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
if ($num_rows > 0)
{
for ($i = 0; $i < sizeof($extension_row); $i++)
{
if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || intval($extension_row[$i]['group_id']) != intval($extensions['_' . $extension_row[$i]['ext_id']]['group_id']))
{
if ($num_rows > 0) {
for ($i = 0; $i < sizeof($extension_row); $i++) {
if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || intval($extension_row[$i]['group_id']) != intval($extensions['_' . $extension_row[$i]['ext_id']]['group_id'])) {
$sql_ary = array(
'comment' => (string)$extensions['_' . $extension_row[$i]['ext_id']]['comment'],
'group_id' => (int)$extensions['_' . $extension_row[$i]['ext_id']]['group_id']
@ -102,8 +114,7 @@ if ($submit && $mode == 'extensions')
$sql = 'UPDATE ' . BB_EXTENSIONS . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . '
WHERE ext_id = ' . (int)$extension_row[$i]['ext_id'];
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not update extension informations');
}
}
@ -115,12 +126,10 @@ if ($submit && $mode == 'extensions')
$extension_id_sql = implode(', ', $extension_id_list);
if ($extension_id_sql != '')
{
if ($extension_id_sql != '') {
$sql = 'DELETE FROM ' . BB_EXTENSIONS . ' WHERE ext_id IN (' . $extension_id_sql . ')';
if( !$result = DB()->sql_query($sql) )
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not delete extensions');
}
}
@ -129,22 +138,19 @@ if ($submit && $mode == 'extensions')
$extension = get_var('add_extension', '');
$extension_explain = get_var('add_extension_explain', '');
$extension_group = get_var('add_group_select', 0);
$add = ( isset($_POST['add_extension_check']) ) ? TRUE : FALSE;
$add = (isset($_POST['add_extension_check'])) ? true : false;
if ($extension != '' && $add)
{
if ($extension != '' && $add) {
$template->assign_vars(array(
'ADD_EXTENSION' => $extension,
'ADD_EXTENSION_EXPLAIN' => $extension_explain,
));
if (!@$error)
{
if (!@$error) {
// check extension
$sql = 'SELECT extension FROM ' . BB_EXTENSIONS;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query extensions');
}
@ -152,15 +158,11 @@ if ($submit && $mode == 'extensions')
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows > 0)
{
for ($i = 0; $i < $num_rows; $i++)
{
if (strtolower(trim($row[$i]['extension'])) == strtolower(trim($extension)))
{
$error = TRUE;
if( isset($error_msg) )
{
if ($num_rows > 0) {
for ($i = 0; $i < $num_rows; $i++) {
if (strtolower(trim($row[$i]['extension'])) == strtolower(trim($extension))) {
$error = true;
if (isset($error_msg)) {
$error_msg .= '<br />';
}
$error_msg .= sprintf($lang['EXTENSION_EXIST'], strtolower(trim($extension)));
@ -168,8 +170,7 @@ if ($submit && $mode == 'extensions')
}
}
if (!@$error)
{
if (!@$error) {
$sql_ary = array(
'group_id' => (int)$extension_group,
'extension' => (string)strtolower($extension),
@ -178,23 +179,19 @@ if ($submit && $mode == 'extensions')
$sql = 'INSERT INTO ' . BB_EXTENSIONS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not add extension');
}
}
}
}
if (!@$error)
{
if (!@$error) {
bb_die($lang['ATTACH_CONFIG_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '<a href="admin_extensions.php?mode=extensions">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
if ($mode == 'extensions')
{
if ($mode == 'extensions') {
// Extensions
$template->assign_vars(array(
'TPL_ATTACH_EXTENSIONS' => true,
@ -202,14 +199,11 @@ if ($mode == 'extensions')
'S_ATTACH_ACTION' => 'admin_extensions.php?mode=extensions',
));
if ($submit)
{
if ($submit) {
$template->assign_vars(array(
'S_ADD_GROUP_SELECT' => group_select('add_group_select', $extension_group))
);
}
else
{
} else {
$template->assign_vars(array(
'S_ADD_GROUP_SELECT' => group_select('add_group_select'))
);
@ -217,8 +211,7 @@ if ($mode == 'extensions')
$sql = 'SELECT * FROM ' . BB_EXTENSIONS . ' ORDER BY group_id';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get extension informations #2');
}
@ -226,23 +219,18 @@ if ($mode == 'extensions')
$num_extension_row = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_extension_row > 0)
{
if ($num_extension_row > 0) {
$extension_row = sort_multi_array($extension_row, 'group_name', 'ASC');
for ($i = 0; $i < $num_extension_row; $i++)
{
if ($submit)
{
for ($i = 0; $i < $num_extension_row; $i++) {
if ($submit) {
$template->assign_block_vars('extension_row', array(
'EXT_ID' => $extension_row[$i]['ext_id'],
'EXTENSION' => $extension_row[$i]['extension'],
'EXTENSION_EXPLAIN' => $extension_explain_list[$i],
'S_GROUP_SELECT' => group_select('group_select[]', $group_select_list[$i]))
);
}
else
{
} else {
$template->assign_block_vars('extension_row', array(
'EXT_ID' => $extension_row[$i]['ext_id'],
'EXTENSION' => $extension_row[$i]['extension'],
@ -252,12 +240,10 @@ if ($mode == 'extensions')
}
}
}
}
// Extension Groups
if ($submit && $mode == 'groups')
{
if ($submit && $mode == 'groups') {
// Change Extension Groups ?
$group_change_list = get_var('group_change_list', array(0));
$extension_group_list = get_var('extension_group_list', array(''));
@ -270,19 +256,15 @@ if ($submit && $mode == 'groups')
$allowed_list = array();
for ($i = 0; $i < sizeof($group_allowed_list); $i++)
{
for ($j = 0; $j < sizeof($group_change_list); $j++)
{
if ($group_allowed_list[$i] == $group_change_list[$j])
{
for ($i = 0; $i < sizeof($group_allowed_list); $i++) {
for ($j = 0; $j < sizeof($group_change_list); $j++) {
if ($group_allowed_list[$i] == $group_change_list[$j]) {
$allowed_list[$j] = 1;
}
}
}
for ($i = 0; $i < sizeof($group_change_list); $i++)
{
for ($i = 0; $i < sizeof($group_change_list); $i++) {
$allowed = (isset($allowed_list[$i])) ? 1 : 0;
$filesize_list[$i] = ($size_select_list[$i] == 'kb') ? round($filesize_list[$i] * 1024) : (($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i]);
@ -299,8 +281,7 @@ if ($submit && $mode == 'groups')
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . '
WHERE group_id = ' . (int)$group_change_list[$i];
if (!(DB()->sql_query($sql)))
{
if (!(DB()->sql_query($sql))) {
bb_die('Could not update extension groups informations');
}
}
@ -310,14 +291,12 @@ if ($submit && $mode == 'groups')
$group_id_sql = implode(', ', $group_id_list);
if ($group_id_sql != '')
{
if ($group_id_sql != '') {
$sql = 'DELETE
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id IN (' . $group_id_sql . ')';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not delete extension groups');
}
@ -326,8 +305,7 @@ if ($submit && $mode == 'groups')
SET group_id = 0
WHERE group_id IN (' . $group_id_sql . ')';
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not assign extensions to pending group');
}
}
@ -341,15 +319,13 @@ if ($submit && $mode == 'groups')
$size_select = get_var('add_size_select', '');
$is_allowed = (isset($_POST['add_allowed'])) ? 1 : 0;
$add = ( isset($_POST['add_extension_group_check']) ) ? TRUE : FALSE;
$add = (isset($_POST['add_extension_group_check'])) ? true : false;
if ($extension_group != '' && $add)
{
if ($extension_group != '' && $add) {
// check Extension Group
$sql = 'SELECT group_name FROM ' . BB_EXTENSION_GROUPS;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query extension groups table');
}
@ -357,15 +333,11 @@ if ($submit && $mode == 'groups')
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows > 0)
{
for ($i = 0; $i < $num_rows; $i++)
{
if ($row[$i]['group_name'] == $extension_group)
{
$error = TRUE;
if( isset($error_msg) )
{
if ($num_rows > 0) {
for ($i = 0; $i < $num_rows; $i++) {
if ($row[$i]['group_name'] == $extension_group) {
$error = true;
if (isset($error_msg)) {
$error_msg .= '<br />';
}
$error_msg .= sprintf($lang['EXTENSION_GROUP_EXIST'], $extension_group);
@ -373,8 +345,7 @@ if ($submit && $mode == 'groups')
}
}
if (!@$error)
{
if (!@$error) {
$filesize = ($size_select == 'kb') ? round($filesize * 1024) : (($size_select == 'mb') ? round($filesize * 1048576) : $filesize);
$sql_ary = array(
@ -389,36 +360,28 @@ if ($submit && $mode == 'groups')
$sql = 'INSERT INTO ' . BB_EXTENSION_GROUPS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
if (!(DB()->sql_query($sql)))
{
if (!(DB()->sql_query($sql))) {
bb_die('Could not add extension group');
}
}
}
if (!@$error)
{
if (!@$error) {
bb_die($lang['ATTACH_CONFIG_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '<a href="admin_extensions.php?mode=groups">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
if ($mode == 'groups')
{
if ($mode == 'groups') {
// Extension Groups
if (!$size && !$submit)
{
if (!$size && !$submit) {
$max_add_filesize = $attach_config['max_filesize'];
$size = ($max_add_filesize >= 1048576) ? 'mb' : (($max_add_filesize >= 1024) ? 'kb' : 'b');
}
if ($max_add_filesize >= 1048576)
{
if ($max_add_filesize >= 1048576) {
$max_add_filesize = round($max_add_filesize / 1048576 * 100) / 100;
}
else if ( $max_add_filesize >= 1024)
{
} elseif ($max_add_filesize >= 1024) {
$max_add_filesize = round($max_add_filesize / 1024 * 100) / 100;
}
@ -437,8 +400,7 @@ if ($mode == 'groups')
$sql = 'SELECT * FROM ' . BB_EXTENSION_GROUPS;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get extension group informations');
}
@ -446,22 +408,17 @@ if ($mode == 'groups')
$num_extension_group = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($i = 0; $i < $num_extension_group; $i++)
{
for ($i = 0; $i < $num_extension_group; $i++) {
// Format the filesize
if (!$extension_group[$i]['max_filesize'])
{
if (!$extension_group[$i]['max_filesize']) {
$extension_group[$i]['max_filesize'] = $attach_config['max_filesize'];
}
$size_format = ($extension_group[$i]['max_filesize'] >= 1048576) ? 'mb' : (($extension_group[$i]['max_filesize'] >= 1024) ? 'kb' : 'b');
if ( $extension_group[$i]['max_filesize'] >= 1048576)
{
if ($extension_group[$i]['max_filesize'] >= 1048576) {
$extension_group[$i]['max_filesize'] = round($extension_group[$i]['max_filesize'] / 1048576 * 100) / 100;
}
else if($extension_group[$i]['max_filesize'] >= 1024)
{
} elseif ($extension_group[$i]['max_filesize'] >= 1024) {
$extension_group[$i]['max_filesize'] = round($extension_group[$i]['max_filesize'] / 1024 * 100) / 100;
}
@ -483,12 +440,10 @@ if ($mode == 'groups')
'U_FORUM_PERMISSIONS' => "admin_extensions.php?mode=$mode&amp;e_mode=perm&amp;e_group=" . $extension_group[$i]['group_id'],
));
if ($viewgroup && $viewgroup == $extension_group[$i]['group_id'])
{
if ($viewgroup && $viewgroup == $extension_group[$i]['group_id']) {
$sql = 'SELECT comment, extension FROM ' . BB_EXTENSIONS . ' WHERE group_id = ' . (int)$viewgroup;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get extension informations #3');
}
@ -496,8 +451,7 @@ if ($mode == 'groups')
$num_extension = DB()->num_rows($result);
DB()->sql_freeresult($result);
for ($j = 0; $j < $num_extension; $j++)
{
for ($j = 0; $j < $num_extension; $j++) {
$template->assign_block_vars('grouprow.extensionrow', array(
'EXPLANATION' => $extension[$j]['comment'],
'EXTENSION' => $extension[$j]['extension'])
@ -507,73 +461,59 @@ if ($mode == 'groups')
}
}
if ($e_mode == 'perm')
{
if ($e_mode == 'perm') {
$group = get_var('e_group', 0);
$add_forum = (isset($_POST['add_forum'])) ? TRUE : FALSE;
$delete_forum = (isset($_POST['del_forum'])) ? TRUE : FALSE;
$add_forum = (isset($_POST['add_forum'])) ? true : false;
$delete_forum = (isset($_POST['del_forum'])) ? true : false;
if (isset($_POST['close_perm']))
{
if (isset($_POST['close_perm'])) {
$e_mode = '';
}
}
// Add Forums
if (@$add_forum && $e_mode == 'perm' && $group)
{
if (@$add_forum && $e_mode == 'perm' && $group) {
$add_forums_list = get_var('entries', array(0));
$add_all_forums = FALSE;
$add_all_forums = false;
for ($i = 0; $i < sizeof($add_forums_list); $i++)
{
if ($add_forums_list[$i] == 0)
{
$add_all_forums = TRUE;
for ($i = 0; $i < sizeof($add_forums_list); $i++) {
if ($add_forums_list[$i] == 0) {
$add_all_forums = true;
}
}
// If we add ALL FORUMS, we are able to overwrite the Permissions
if ($add_all_forums)
{
if ($add_all_forums) {
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . " SET forum_permissions = '' WHERE group_id = " . (int)$group;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not update permissions #1');
}
}
// Else we have to add Permissions
if (!$add_all_forums)
{
if (!$add_all_forums) {
$sql = 'SELECT forum_permissions
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id = ' . intval($group) . '
LIMIT 1';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get group permissions from ' . BB_EXTENSION_GROUPS);
}
$row = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
if (trim($row['forum_permissions']) == '')
{
if (trim($row['forum_permissions']) == '') {
$auth_p = array();
}
else
{
} else {
$auth_p = auth_unpack($row['forum_permissions']);
}
// Generate array for Auth_Pack, do not add doubled forums
for ($i = 0; $i < sizeof($add_forums_list); $i++)
{
if (!in_array($add_forums_list[$i], $auth_p))
{
for ($i = 0; $i < sizeof($add_forums_list); $i++) {
if (!in_array($add_forums_list[$i], $auth_p)) {
$auth_p[] = $add_forums_list[$i];
}
}
@ -582,17 +522,14 @@ if (@$add_forum && $e_mode == 'perm' && $group)
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . " SET forum_permissions = '" . attach_mod_sql_escape($auth_bitstream) . "' WHERE group_id = " . (int)$group;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not update permissions #2');
}
}
}
// Delete Forums
if (@$delete_forum && $e_mode == 'perm' && $group)
{
if (@$delete_forum && $e_mode == 'perm' && $group) {
$delete_forums_list = get_var('entries', array(0));
// Get the current Forums
@ -601,8 +538,7 @@ if (@$delete_forum && $e_mode == 'perm' && $group)
WHERE group_id = ' . intval($group) . '
LIMIT 1';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get group permissions from ' . BB_EXTENSION_GROUPS);
}
@ -613,10 +549,8 @@ if (@$delete_forum && $e_mode == 'perm' && $group)
$auth_p = array();
// Generate array for Auth_Pack, delete the chosen ones
for ($i = 0; $i < sizeof($auth_p2); $i++)
{
if (!in_array($auth_p2[$i], $delete_forums_list))
{
for ($i = 0; $i < sizeof($auth_p2); $i++) {
if (!in_array($auth_p2[$i], $delete_forums_list)) {
$auth_p[] = $auth_p2[$i];
}
}
@ -625,22 +559,19 @@ if (@$delete_forum && $e_mode == 'perm' && $group)
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . " SET forum_permissions = '" . attach_mod_sql_escape($auth_bitstream) . "' WHERE group_id = " . (int)$group;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not update permissions #3');
}
}
// Display the Group Permissions Box for configuring it
if ($e_mode == 'perm' && $group)
{
if ($e_mode == 'perm' && $group) {
$sql = 'SELECT group_name, forum_permissions
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id = ' . intval($group) . '
LIMIT 1';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get group name from ' . BB_EXTENSION_GROUPS);
}
@ -652,32 +583,26 @@ if ($e_mode == 'perm' && $group)
$forum_perm = array();
if ($allowed_forums == '')
{
if ($allowed_forums == '') {
$forum_perm[0]['forum_id'] = 0;
$forum_perm[0]['forum_name'] = $lang['PERM_ALL_FORUMS'];
}
else
{
} else {
$forum_p = array();
$act_id = 0;
$forum_p = auth_unpack($allowed_forums);
$sql = "SELECT forum_id, forum_name FROM " . BB_FORUMS . " WHERE forum_id IN (" . implode(', ', $forum_p) . ")";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get forum names');
}
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$forum_perm[$act_id]['forum_id'] = $row['forum_id'];
$forum_perm[$act_id]['forum_name'] = $row['forum_name'];
$act_id++;
}
}
for ($i = 0; $i < sizeof($forum_perm); $i++)
{
for ($i = 0; $i < sizeof($forum_perm); $i++) {
$template->assign_block_vars('allow_option_values', array(
'VALUE' => $forum_perm[$i]['forum_id'],
'OPTION' => htmlCHR($forum_perm[$i]['forum_name']))
@ -694,19 +619,16 @@ if ($e_mode == 'perm' && $group)
$sql = "SELECT forum_id, forum_name FROM " . BB_FORUMS;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get forums #1');
}
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$forum_option_values[intval($row['forum_id'])] = $row['forum_name'];
}
DB()->sql_freeresult($result);
foreach ($forum_option_values as $value => $option)
{
foreach ($forum_option_values as $value => $option) {
$template->assign_block_vars('forum_option_values', array(
'VALUE' => $value,
'OPTION' => htmlCHR($option))
@ -717,13 +639,11 @@ if ($e_mode == 'perm' && $group)
$sql = "SELECT forum_id, forum_name FROM " . BB_FORUMS . " WHERE auth_attachments < " . AUTH_ADMIN;
if (!($f_result = DB()->sql_query($sql)))
{
if (!($f_result = DB()->sql_query($sql))) {
bb_die('Could not get forums #2');
}
while ($row = DB()->sql_fetchrow($f_result))
{
while ($row = DB()->sql_fetchrow($f_result)) {
$forum_id = $row['forum_id'];
$sql = "SELECT forum_permissions
@ -731,8 +651,7 @@ if ($e_mode == 'perm' && $group)
WHERE allow_group = 1
ORDER BY group_name ASC";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query extension groups');
}
@ -740,20 +659,17 @@ if ($e_mode == 'perm' && $group)
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
$found_forum = FALSE;
$found_forum = false;
for ($i = 0; $i < $num_rows; $i++)
{
for ($i = 0; $i < $num_rows; $i++) {
$allowed_forums = auth_unpack(trim($rows[$i]['forum_permissions']));
if (in_array($forum_id, $allowed_forums) || trim($rows[$i]['forum_permissions']) == '')
{
$found_forum = TRUE;
if (in_array($forum_id, $allowed_forums) || trim($rows[$i]['forum_permissions']) == '') {
$found_forum = true;
break;
}
}
if (!$found_forum)
{
if (!$found_forum) {
$empty_perm_forums[$forum_id] = $row['forum_name'];
}
}
@ -761,19 +677,16 @@ if ($e_mode == 'perm' && $group)
$message = '';
foreach ($empty_perm_forums as $forum_id => $forum_name)
{
foreach ($empty_perm_forums as $forum_id => $forum_name) {
$message .= ($message == '') ? $forum_name : '<br />' . $forum_name;
}
if (sizeof($empty_perm_forums) > 0)
{
if (sizeof($empty_perm_forums) > 0) {
$template->assign_vars(array('ERROR_MESSAGE' => $lang['NOTE_ADMIN_EMPTY_GROUP_PERMISSIONS'] . $message));
}
}
if (@$error)
{
if (@$error) {
$template->assign_vars(array('ERROR_MESSAGE' => $error_msg));
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['FORUMS']['PRUNE'] = basename(__FILE__);
return;
}
@ -11,14 +33,11 @@ $all_forums = -1;
$pruned_total = 0;
$prune_performed = false;
if (isset($_REQUEST['submit']))
{
if (!$var =& $_REQUEST['f'] OR !$f_selected = get_id_ary($var))
{
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)))
{
if (!$var =& $_REQUEST['prunedays'] or !$prunedays = abs(intval($var))) {
bb_die($lang['NOT_DAYS']);
}
@ -29,8 +48,7 @@ if (isset($_REQUEST['submit']))
$sql = "SELECT forum_id, forum_name FROM " . BB_FORUMS . " $where_sql";
foreach (DB()->fetch_rowset($sql) as $i => $row)
{
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;
@ -41,12 +59,10 @@ if (isset($_REQUEST['submit']))
'PRUNED_TOPICS' => $pruned_topics,
));
}
if (!$prune_performed)
{
if (!$prune_performed) {
bb_die($lang['NONE_SELECTED']);
}
if (!$pruned_total)
{
if (!$pruned_total) {
bb_die($lang['NO_SEARCH_MATCH']);
}
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['FORUMS']['PERMISSIONS'] = basename(__FILE__);
return;
}
@ -24,13 +46,20 @@ $forum_auth_fields = array(
// 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(
@ -44,67 +73,50 @@ $simple_auth_types = array(
);
$field_names = array();
foreach ($forum_auth_fields as $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);
if (@$_REQUEST[POST_FORUM_URL])
{
if (@$_REQUEST[POST_FORUM_URL]) {
$forum_id = (int)$_REQUEST[POST_FORUM_URL];
$forum_sql = "WHERE forum_id = $forum_id";
}
else
{
} else {
unset($forum_id);
$forum_sql = '';
}
if( isset($_GET['adv']) )
{
if (isset($_GET['adv'])) {
$adv = intval($_GET['adv']);
}
else
{
} else {
unset($adv);
}
//
// Start program proper
//
if( isset($_POST['submit']) )
{
if (isset($_POST['submit'])) {
$sql = '';
if(!empty($forum_id))
{
if(isset($_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++)
{
for ($i = 0; $i < count($simple_ary); $i++) {
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
if (is_array($simple_ary))
{
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++)
{
} 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)
{
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
$value = AUTH_REG;
}
}
@ -115,10 +127,8 @@ if( isset($_POST['submit']) )
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
if ($sql != '')
{
if (!DB()->sql_query($sql))
{
if ($sql != '') {
if (!DB()->sql_query($sql)) {
bb_die('Could not update auth table');
}
}
@ -129,7 +139,6 @@ if( isset($_POST['submit']) )
$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
//
@ -139,37 +148,29 @@ if( isset($_POST['submit']) )
//
$forum_rows = DB()->fetch_rowset("SELECT * FROM " . BB_FORUMS . " $forum_sql");
if (empty($forum_id))
{
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
{
} 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))
{
while (list($key, $auth_levels) = each($simple_auth_ary)) {
$matched = 1;
for ($k = 0; $k < count($auth_levels); $k++)
{
for ($k = 0; $k < count($auth_levels); $k++) {
$matched_type = $key;
if ($forum_rows[0][$forum_auth_fields[$k]] != $auth_levels[$k])
{
if ($forum_rows[0][$forum_auth_fields[$k]] != $auth_levels[$k]) {
$matched = 0;
}
}
if ( $matched )
{
if ($matched) {
break;
}
}
@ -178,19 +179,16 @@ else
// If we didn't get a match above then we
// automatically switch into 'advanced' mode
//
if ( !isset($adv) && !$matched )
{
if (!isset($adv) && !$matched) {
$adv = 1;
}
$s_column_span = 0;
if (empty($adv))
{
if (empty($adv)) {
$simple_auth = '<select name="simpleauth">';
for($j = 0; $j < count($simple_auth_types); $j++)
{
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>';
}
@ -203,19 +201,15 @@ else
));
$s_column_span++;
}
else
{
} else {
//
// Output values of individual
// fields
//
for ($j = 0; $j < count($forum_auth_fields); $j++)
{
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++)
{
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>';
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['FORUMS']['PERMISSIONS_LIST'] = basename(__FILE__);
return;
}
@ -9,13 +31,20 @@ 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(
@ -44,78 +73,58 @@ $forum_auth_fields = array(
);
$field_names = array();
foreach ($forum_auth_fields as $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);
if(isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL]))
{
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
{
} else {
unset($forum_id);
$forum_sql = '';
}
if(isset($_GET[POST_CAT_URL]) || isset($_POST[POST_CAT_URL]))
{
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
{
} else {
unset($cat_id);
$cat_sql = '';
}
if( isset($_GET['adv']) )
{
if (isset($_GET['adv'])) {
$adv = intval($_GET['adv']);
}
else
{
} else {
unset($adv);
}
//
// Start program proper
//
if( isset($_POST['submit']) )
{
if (isset($_POST['submit'])) {
$sql = '';
if(!empty($forum_id))
{
if(isset($_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++)
{
for ($i = 0; $i < count($simple_ary); $i++) {
$sql .= (($sql != '') ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i];
}
if (is_array($simple_ary))
{
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++)
{
} 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 )
{
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
$value = AUTH_REG;
}
}
@ -126,27 +135,20 @@ if( isset($_POST['submit']) )
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE forum_id = $forum_id";
}
if ($sql != '')
{
if (!DB()->sql_query($sql))
{
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++)
{
} 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 )
{
if ($forum_auth_fields[$i] == 'auth_vote') {
if ($_POST['auth_vote'] == AUTH_ALL) {
$value = AUTH_REG;
}
}
@ -156,10 +158,8 @@ if( isset($_POST['submit']) )
$sql = "UPDATE " . BB_FORUMS . " SET $sql WHERE cat_id = $cat_id";
if ($sql != '')
{
if (!DB()->sql_query($sql))
{
if ($sql != '') {
if (!DB()->sql_query($sql)) {
bb_die('Could not update auth table #2');
}
}
@ -169,7 +169,6 @@ if( isset($_POST['submit']) )
$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,16 +181,14 @@ $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)))
{
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) )
{
if (empty($forum_id) && empty($cat_id)) {
//
// Output the summary list if no forum id was
// specified
@ -201,8 +198,7 @@ if( empty($forum_id) && empty($cat_id) )
'S_COLUMN_SPAN' => count($forum_auth_fields) + 1,
));
for ($i = 0; $i<count($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]],
));
@ -212,16 +208,14 @@ if( empty($forum_id) && empty($cat_id) )
$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)))
{
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);
for ($i=0; $i<$cat_count; $i++)
{
for ($i = 0; $i < $cat_count; $i++) {
$cat_id = $category_rows[$i]['cat_id'];
$template->assign_block_vars('cat_row', array(
@ -229,23 +223,18 @@ if( empty($forum_id) && empty($cat_id) )
'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'] )
{
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++)
{
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])
{
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;
}
@ -258,9 +247,7 @@ if( empty($forum_id) && empty($cat_id) )
}
}
}
}
else
{
} else {
//
// output the authorisation details if an category id was
// specified
@ -270,8 +257,7 @@ else
// first display the current details for all forums
// in the category
//
for ($i = 0; $i<count($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]],
));
@ -282,8 +268,7 @@ else
FROM " . BB_CATEGORIES . " c
WHERE c.cat_id = $cat_id
ORDER BY c.cat_order";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query categories list #2');
}
@ -297,23 +282,18 @@ else
'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'] )
{
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++)
{
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])
{
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;
}
@ -330,12 +310,10 @@ else
// 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++)
{
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++)
{
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>';
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['FORUMS']['MANAGE'] = basename(__FILE__);
return;
}
@ -32,19 +54,16 @@ $mode = (@$_REQUEST['mode']) ? (string) $_REQUEST['mode'] : '';
$cat_forums = get_cat_forums();
if ($orphan_sf_sql = get_orphan_sf())
{
fix_orphan_sf($orphan_sf_sql, TRUE);
if ($orphan_sf_sql = get_orphan_sf()) {
fix_orphan_sf($orphan_sf_sql, true);
}
$forum_parent = $cat_id = 0;
$forumname = '';
if (isset($_REQUEST['addforum']) || isset($_REQUEST['addcategory']))
{
if (isset($_REQUEST['addforum']) || isset($_REQUEST['addcategory'])) {
$mode = (isset($_REQUEST['addforum'])) ? "addforum" : "addcat";
if ($mode == 'addforum' && isset($_POST['addforum']) && isset($_POST['forumname']) && is_array($_POST['addforum']))
{
if ($mode == 'addforum' && isset($_POST['addforum']) && isset($_POST['forumname']) && is_array($_POST['addforum'])) {
$req_cat_id = array_keys($_POST['addforum']);
$cat_id = $req_cat_id[0];
$forumname = stripslashes($_POST['forumname'][$cat_id]);
@ -53,17 +72,14 @@ if (isset($_REQUEST['addforum']) || isset($_REQUEST['addcategory']))
$show_main_page = false;
if ($mode)
{
switch ($mode)
{
if ($mode) {
switch ($mode) {
case 'addforum':
case 'editforum':
//
// Show form to create/modify a forum
//
if ($mode == 'editforum')
{
if ($mode == 'editforum') {
// $newmode determines if we are going to INSERT or UPDATE after posting?
$l_title = $lang['EDIT_FORUM'];
@ -87,9 +103,7 @@ if ($mode)
$allow_reg_tracker = $row['allow_reg_tracker'];
$allow_porno_topic = $row['allow_porno_topic'];
$self_moderated = $row['self_moderated'];
}
else
{
} else {
$l_title = $lang['CREATE_FORUM'];
$newmode = 'createforum';
$buttonvalue = $lang['CREATE_FORUM'];
@ -107,21 +121,17 @@ if ($mode)
$self_moderated = 0;
}
if (isset($_REQUEST['forum_parent']))
{
if (isset($_REQUEST['forum_parent'])) {
$forum_parent = intval($_REQUEST['forum_parent']);
if ($parent = get_forum_data($forum_parent))
{
if ($parent = get_forum_data($forum_parent)) {
$cat_id = $parent['cat_id'];
}
}
else if (isset($_REQUEST['c']))
{
} elseif (isset($_REQUEST['c'])) {
$cat_id = (int)$_REQUEST['c'];
}
$catlist = get_list('category', $cat_id, TRUE);
$catlist = get_list('category', $cat_id, true);
$forumlocked = $forumunlocked = '';
$forumstatus == (FORUM_LOCKED) ? $forumlocked = 'selected="selected"' : $forumunlocked = 'selected="selected"';
@ -188,24 +198,19 @@ if ($mode)
$allow_porno_topic = (int)$_POST['allow_porno_topic'];
$self_moderated = (int)$_POST['self_moderated'];
if (!$forum_name)
{
if (!$forum_name) {
bb_die('Can not create a forum without a name');
}
if ($forum_parent)
{
if (!$parent = get_forum_data($forum_parent))
{
if ($forum_parent) {
if (!$parent = get_forum_data($forum_parent)) {
bb_die('Parent forum with id <b>' . $forum_parent . '</b> not found');
}
$cat_id = $parent['cat_id'];
$forum_parent = ($parent['forum_parent']) ? $parent['forum_parent'] : $parent['forum_id'];
$forum_order = $parent['forum_order'] + 5;
}
else
{
} else {
$max_order = get_max_forum_order($cat_id);
$forum_order = $max_order + 5;
}
@ -213,8 +218,7 @@ if ($mode)
// Default permissions of public forum
$field_sql = $value_sql = '';
foreach ($default_forum_auth as $field => $value)
{
foreach ($default_forum_auth as $field => $value) {
$field_sql .= ", $field";
$value_sql .= ", $value";
}
@ -260,15 +264,12 @@ if ($mode)
$old_cat_id = $forum_data['cat_id'];
$forum_order = $forum_data['forum_order'];
if (!$forum_name)
{
if (!$forum_name) {
bb_die('Can not modify a forum without a name');
}
if ($forum_parent)
{
if (!$parent = get_forum_data($forum_parent))
{
if ($forum_parent) {
if (!$parent = get_forum_data($forum_parent)) {
bb_die('Parent forum with id <b>' . $forum_parent . '</b> not found');
}
@ -276,18 +277,13 @@ if ($mode)
$forum_parent = ($parent['forum_parent']) ? $parent['forum_parent'] : $parent['forum_id'];
$forum_order = $parent['forum_order'] + 5;
if ($forum_id == $forum_parent)
{
if ($forum_id == $forum_parent) {
bb_die('Ambiguous forum ID. Please select other parent forum');
}
}
else if ($cat_id != $old_cat_id)
{
} elseif ($cat_id != $old_cat_id) {
$max_order = get_max_forum_order($cat_id);
$forum_order = $max_order + 5;
}
else if ($forum_data['forum_parent'])
{
} elseif ($forum_data['forum_parent']) {
$old_parent = $forum_data['forum_parent'];
$forum_order = $cat_forums[$old_cat_id]['f'][$old_parent]['forum_order'] - 5;
}
@ -314,8 +310,7 @@ if ($mode)
WHERE forum_id = $forum_id
");
if ($cat_id != $old_cat_id)
{
if ($cat_id != $old_cat_id) {
change_sf_cat($forum_id, $cat_id, $forum_order);
renumber_order('forum', $cat_id);
}
@ -338,8 +333,7 @@ if ($mode)
//
// Create a category in the DB
//
if (!$new_cat_title = trim($_POST['categoryname']))
{
if (!$new_cat_title = trim($_POST['categoryname'])) {
bb_die('Category name is empty');
}
@ -387,8 +381,7 @@ if ($mode)
//
// Modify a category in the DB
//
if (!$new_cat_title = trim($_POST['cat_title']))
{
if (!$new_cat_title = trim($_POST['cat_title'])) {
bb_die('Category name is empty');
}
@ -397,8 +390,7 @@ if ($mode)
$row = get_info('category', $cat_id);
$cur_cat_title = $row['cat_title'];
if ($cur_cat_title && $cur_cat_title !== $new_cat_title)
{
if ($cur_cat_title && $cur_cat_title !== $new_cat_title) {
check_name_dup('cat', $new_cat_title);
$new_cat_title_sql = DB()->escape($new_cat_title);
@ -455,19 +447,15 @@ if ($mode)
$from_id = (int)$_POST['from_id'];
$to_id = (int)$_POST['to_id'];
if ($to_id == -1)
{
if ($to_id == -1) {
// Delete everything from forum
topic_delete('prune', $from_id, 0, true);
}
else
{
} else {
// Move all posts
$sql = "SELECT * FROM " . BB_FORUMS . " WHERE forum_id IN($from_id, $to_id)";
$result = DB()->query($sql);
if (DB()->num_rows($result) != 2)
{
if (DB()->num_rows($result) != 2) {
bb_die('Ambiguous forum ID');
}
@ -478,15 +466,13 @@ if ($mode)
$start_id = (int)$row['start_id'];
$finish_id = (int)$row['finish_id'];
$per_cycle = 10000;
while (true)
{
while (true) {
set_time_limit(600);
$end_id = $start_id + $per_cycle - 1;
DB()->query("
UPDATE " . BB_POSTS . " SET forum_id = $to_id WHERE post_id BETWEEN $start_id AND $end_id AND forum_id = $from_id
");
if ($end_id > $finish_id)
{
if ($end_id > $finish_id) {
break;
}
$start_id += $per_cycle;
@ -515,16 +501,12 @@ if ($mode)
$catinfo = get_info('category', $cat_id);
$categories_count = $catinfo['number'];
if ($categories_count == 1)
{
if ($categories_count == 1) {
$row = DB()->fetch_row("SELECT COUNT(*) AS forums_count FROM " . BB_FORUMS);
if ($row['forums_count'] > 0)
{
if ($row['forums_count'] > 0) {
bb_die($lang['MUST_DELETE_FORUMS']);
}
else
{
} else {
$template->assign_var('NOWHERE_TO_MOVE', $lang['NOWHERE_TO_MOVE']);
}
}
@ -554,8 +536,7 @@ if ($mode)
$from_id = (int)$_POST['from_id'];
$to_id = (int)$_POST['to_id'];
if ($from_id == $to_id || !cat_exists($from_id) || !cat_exists($to_id))
{
if ($from_id == $to_id || !cat_exists($from_id) || !cat_exists($to_id)) {
bb_die('Bad input');
}
@ -593,60 +574,46 @@ if ($mode)
$cat_id = $forum_info['cat_id'];
$move_down_forum_id = FALSE;
$move_down_forum_id = false;
$forums = $cat_forums[$cat_id]['f_ord'];
$forum_order = $forum_info['forum_order'];
$prev_forum = (isset($forums[$forum_order - 10])) ? $forums[$forum_order - 10] : FALSE;
$next_forum = (isset($forums[$forum_order + 10])) ? $forums[$forum_order + 10] : FALSE;
$prev_forum = (isset($forums[$forum_order - 10])) ? $forums[$forum_order - 10] : false;
$next_forum = (isset($forums[$forum_order + 10])) ? $forums[$forum_order + 10] : false;
// move selected forum ($forum_id) UP
if ($move < 0 && $prev_forum)
{
if ($forum_info['forum_parent'] && $prev_forum['forum_parent'] != $forum_info['forum_parent'])
{
if ($move < 0 && $prev_forum) {
if ($forum_info['forum_parent'] && $prev_forum['forum_parent'] != $forum_info['forum_parent']) {
$show_main_page = true;
break;
}
else if ($move_down_forum_id = get_prev_root_forum_id($forums, $forum_order))
{
} elseif ($move_down_forum_id = get_prev_root_forum_id($forums, $forum_order)) {
$move_up_forum_id = $forum_id;
$move_down_ord_val = (get_sf_count($forum_id) + 1) * 10;
$move_up_ord_val = ((get_sf_count($move_down_forum_id) + 1) * 10) + $move_down_ord_val;
$move_down_forum_order = $cat_forums[$cat_id]['f'][$move_down_forum_id]['forum_order'];
}
}
// move selected forum ($forum_id) DOWN
else if ($move > 0 && $next_forum)
{
if ($forum_info['forum_parent'] && $next_forum['forum_parent'] != $forum_info['forum_parent'])
{
} // move selected forum ($forum_id) DOWN
elseif ($move > 0 && $next_forum) {
if ($forum_info['forum_parent'] && $next_forum['forum_parent'] != $forum_info['forum_parent']) {
$show_main_page = true;
break;
}
else if ($move_up_forum_id = get_next_root_forum_id($forums, $forum_order))
{
} elseif ($move_up_forum_id = get_next_root_forum_id($forums, $forum_order)) {
$move_down_forum_id = $forum_id;
$move_down_forum_order = $forum_order;
$move_down_ord_val = (get_sf_count($move_up_forum_id) + 1) * 10;
$move_up_ord_val = ((get_sf_count($move_down_forum_id) + 1) * 10) + $move_down_ord_val;
}
}
else
{
} else {
$show_main_page = true;
break;
}
if ($forum_info['forum_parent'])
{
if ($forum_info['forum_parent']) {
DB()->query("
UPDATE " . BB_FORUMS . " SET
forum_order = forum_order + $move
WHERE forum_id = $forum_id
");
}
else if ($move_down_forum_id)
{
} elseif ($move_down_forum_id) {
DB()->query("
UPDATE " . BB_FORUMS . " SET
forum_order = forum_order + $move_down_ord_val
@ -700,8 +667,7 @@ if ($mode)
}
}
if (!$mode || $show_main_page)
{
if (!$mode || $show_main_page) {
$template->assign_vars(array(
'TPL_FORUMS_LIST' => true,
@ -710,42 +676,32 @@ if (!$mode || $show_main_page)
));
$sql = "SELECT cat_id, cat_title, cat_order FROM " . BB_CATEGORIES . " ORDER BY cat_order";
if (!$q_categories = DB()->sql_query($sql))
{
if (!$q_categories = DB()->sql_query($sql)) {
bb_die('Could not query categories list');
}
if ($total_categories = DB()->num_rows($q_categories))
{
if ($total_categories = DB()->num_rows($q_categories)) {
$category_rows = DB()->sql_fetchrowset($q_categories);
$where_cat_sql = $req_cat_id = '';
if ($c =& $_REQUEST['c'])
{
if ($c !== 'all')
{
if ($c =& $_REQUEST['c']) {
if ($c !== 'all') {
$req_cat_id = (int)$c;
$where_cat_sql = "WHERE cat_id = $req_cat_id";
}
else
{
} else {
$req_cat_id = 'all';
}
}
else
{
} else {
$where_cat_sql = "WHERE cat_id = '-1'";
}
$sql = "SELECT * FROM " . BB_FORUMS . " $where_cat_sql ORDER BY cat_id, forum_order";
if (!$q_forums = DB()->sql_query($sql))
{
if (!$q_forums = DB()->sql_query($sql)) {
bb_die('Could not query forums information');
}
if ($total_forums = DB()->num_rows($q_forums))
{
if ($total_forums = DB()->num_rows($q_forums)) {
$forum_rows = DB()->sql_fetchrowset($q_forums);
}
@ -761,8 +717,7 @@ if (!$mode || $show_main_page)
'FORUMS_COUNT' => $total_forums,
));
for ($i = 0; $i < $total_categories; $i++)
{
for ($i = 0; $i < $total_categories; $i++) {
$cat_id = $category_rows[$i]['cat_id'];
$template->assign_block_vars("c", array(
@ -780,16 +735,13 @@ if (!$mode || $show_main_page)
'U_CREATE_FORUM' => "admin_forums.php?mode=addforum&amp;c=$cat_id",
));
for ($j = 0; $j < $total_forums; $j++)
{
for ($j = 0; $j < $total_forums; $j++) {
$forum_id = $forum_rows[$j]['forum_id'];
$bgr_class = (!($j % 2)) ? $bgr_class_2 : $bgr_class_1;
$row_bgr = " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"";
if ($forum_rows[$j]['cat_id'] == $cat_id)
{
if ($forum_rows[$j]['cat_id'] == $cat_id) {
$template->assign_block_vars("c.f", array(
'FORUM_NAME' => htmlCHR($forum_rows[$j]['forum_name']),
'FORUM_DESC' => htmlCHR($forum_rows[$j]['forum_desc']),
@ -814,7 +766,6 @@ if (!$mode || $show_main_page)
'U_FORUM_MOVE_DOWN' => "admin_forums.php?mode=forum_order&amp;move=15&amp;f=$forum_id&amp;c=$req_cat_id",
'U_FORUM_RESYNC' => "admin_forums.php?mode=forum_sync&amp;f=$forum_id",
));
}// if ... forumid == catid
} // for ... forums
} // for ... categories
@ -826,8 +777,7 @@ print_page('admin_forums.tpl', 'admin');
// Functions
function get_info($mode, $id)
{
switch($mode)
{
switch ($mode) {
case 'category':
$table = BB_CATEGORIES;
$idfield = 'cat_id';
@ -843,8 +793,7 @@ function get_info ($mode, $id)
break;
}
$sql = "SELECT count(*) as total FROM $table";
if( !$result = DB()->sql_query($sql) )
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get forum / category information #1');
}
$count = DB()->sql_fetchrow($result);
@ -852,13 +801,11 @@ function get_info ($mode, $id)
$sql = "SELECT * FROM $table WHERE $idfield = $id";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get forum / category information #2');
}
if (DB()->num_rows($result) != 1)
{
if (DB()->num_rows($result) != 1) {
bb_die('Forum / category does not exist or multiple forums / categories with ID ' . $id);
}
@ -869,8 +816,7 @@ function get_info ($mode, $id)
function get_list($mode, $id, $select)
{
switch($mode)
{
switch ($mode) {
case 'category':
$table = BB_CATEGORIES;
$idfield = 'cat_id';
@ -891,24 +837,20 @@ function get_list ($mode, $id, $select)
}
$sql = "SELECT * FROM $table";
if( $select == 0 )
{
if ($select == 0) {
$sql .= " WHERE $idfield <> $id";
}
$sql .= " ORDER BY $order";
if( !$result = DB()->sql_query($sql) )
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get list of categories / forums #1');
}
$catlist = '';
while( $row = DB()->sql_fetchrow($result) )
{
while ($row = DB()->sql_fetchrow($result)) {
$s = '';
if ($row[$idfield] == $id)
{
if ($row[$idfield] == $id) {
$s = ' selected="selected"';
}
$catlist .= '<option value="' . $row[$idfield] . '"' . $s . '>&nbsp;' . htmlCHR(str_short($row[$namefield], 60)) . '</option>\n';
@ -919,8 +861,7 @@ function get_list ($mode, $id, $select)
function renumber_order($mode, $cat = 0)
{
switch($mode)
{
switch ($mode) {
case 'category':
$table = BB_CATEGORIES;
$idfield = 'cat_id';
@ -941,43 +882,36 @@ function renumber_order ($mode, $cat = 0)
}
$sql = "SELECT * FROM $table";
if( $cat != 0)
{
if ($cat != 0) {
$sql .= " WHERE $catfield = $cat";
}
$sql .= " ORDER BY $orderfield ASC";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get list of categories / forums #2');
}
$i = 10;
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$sql = "UPDATE $table SET $orderfield = $i WHERE $idfield = " . $row[$idfield];
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not update order fields');
}
$i += 10;
}
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get list of categories / forums #3');
}
}
function get_cat_forums ($cat_id = FALSE)
function get_cat_forums($cat_id = false)
{
$forums = array();
$where_sql = '';
if ($cat_id = intval($cat_id))
{
if ($cat_id = intval($cat_id)) {
$where_sql = "AND f.cat_id = $cat_id";
}
@ -987,15 +921,12 @@ function get_cat_forums ($cat_id = FALSE)
$where_sql
ORDER BY c.cat_order, f.cat_id, f.forum_order";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get list of categories / forums #4');
}
if ($rowset = DB()->sql_fetchrowset($result))
{
foreach ($rowset as $rid => $row)
{
if ($rowset = DB()->sql_fetchrowset($result)) {
foreach ($rowset as $rid => $row) {
$forums[$row['cat_id']]['cat_title'] = $row['cat_title'];
$forums[$row['cat_id']]['f'][$row['forum_id']] = $row;
$forums[$row['cat_id']]['f_ord'][$row['forum_order']] = $row;
@ -1011,12 +942,9 @@ function get_sf_count ($forum_id)
$sf_count = 0;
foreach ($cat_forums as $cid => $c)
{
foreach ($c['f'] as $fid => $f)
{
if ($f['forum_parent'] == $forum_id)
{
foreach ($cat_forums as $cid => $c) {
foreach ($c['f'] as $fid => $f) {
if ($f['forum_parent'] == $forum_id) {
$sf_count++;
}
}
@ -1029,16 +957,14 @@ function get_prev_root_forum_id ($forums, $curr_forum_order)
{
$i = $curr_forum_order - 10;
while ($i > 0)
{
if (isset($forums[$i]) && !$forums[$i]['forum_parent'])
{
while ($i > 0) {
if (isset($forums[$i]) && !$forums[$i]['forum_parent']) {
return $forums[$i]['forum_id'];
}
$i = $i - 10;
}
return FALSE;
return false;
}
function get_next_root_forum_id($forums, $curr_forum_order)
@ -1046,16 +972,14 @@ function get_next_root_forum_id ($forums, $curr_forum_order)
$i = $curr_forum_order + 10;
$limit = (count($forums) * 10) + 10;
while ($i < $limit)
{
if (isset($forums[$i]) && !$forums[$i]['forum_parent'])
{
while ($i < $limit) {
if (isset($forums[$i]) && !$forums[$i]['forum_parent']) {
return $forums[$i]['forum_id'];
}
$i = $i + 10;
}
return FALSE;
return false;
}
function get_orphan_sf()
@ -1065,19 +989,13 @@ function get_orphan_sf ()
$last_root = 0;
$bad_sf_ary = array();
foreach ($cat_forums as $cid => $c)
{
foreach ($c['f'] as $fid => $f)
{
if ($f['forum_parent'])
{
if ($f['forum_parent'] != $last_root)
{
foreach ($cat_forums as $cid => $c) {
foreach ($c['f'] as $fid => $f) {
if ($f['forum_parent']) {
if ($f['forum_parent'] != $last_root) {
$bad_sf_ary[] = $f['forum_id'];
}
}
else
{
} else {
$last_root = $f['forum_id'];
}
}
@ -1086,33 +1004,28 @@ function get_orphan_sf ()
return implode(',', $bad_sf_ary);
}
function fix_orphan_sf ($orphan_sf_sql = '', $show_mess = FALSE)
function fix_orphan_sf($orphan_sf_sql = '', $show_mess = false)
{
global $lang;
$done_mess = '';
if (!$orphan_sf_sql)
{
if (!$orphan_sf_sql) {
$orphan_sf_sql = get_orphan_sf();
}
if ($orphan_sf_sql)
{
if ($orphan_sf_sql) {
$sql = "UPDATE " . BB_FORUMS . " SET forum_parent = 0, show_on_index = 1 WHERE forum_id IN($orphan_sf_sql)";
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not change subforums data');
}
if ($affectedrows = DB()->affected_rows())
{
if ($affectedrows = DB()->affected_rows()) {
$done_mess = 'Subforums data corrected. <b>' . $affectedrows . '</b> orphan subforum(s) moved to root level.';
}
if ($show_mess)
{
if ($show_mess) {
$message = $done_mess . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_FORUMADMIN'], '<a href="admin_forums.php">', '</a>') . '<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
@ -1129,14 +1042,11 @@ function sf_get_list ($mode, $exclude = 0, $select = 0)
$opt = '';
if ($mode == 'forum')
{
foreach ($cat_forums as $cid => $c)
{
if ($mode == 'forum') {
foreach ($cat_forums as $cid => $c) {
$opt .= '<optgroup label="&nbsp;' . htmlCHR($c['cat_title']) . '">';
foreach ($c['f'] as $fid => $f)
{
foreach ($c['f'] as $fid => $f) {
$selected = ($fid == $select) ? HTML_SELECTED : '';
$disabled = ($fid == $exclude && !$forum_parent) ? HTML_DISABLED : '';
$style = ($disabled) ? ' style="color: gray" ' : (($fid == $exclude) ? ' style="color: darkred" ' : '');
@ -1154,18 +1064,15 @@ function get_forum_data ($forum_id)
{
global $cat_forums;
foreach ($cat_forums as $cid => $c)
{
foreach ($c['f'] as $fid => $f)
{
if ($fid == $forum_id)
{
foreach ($cat_forums as $cid => $c) {
foreach ($c['f'] as $fid => $f) {
if ($fid == $forum_id) {
return $f;
}
}
}
return FALSE;
return false;
}
function get_max_forum_order($cat_id)
@ -1183,21 +1090,17 @@ function check_name_dup ($mode, $name, $die_on_error = true)
{
$name_sql = DB()->escape($name);
if ($mode == 'cat')
{
if ($mode == 'cat') {
$what_checked = 'category';
$sql = "SELECT cat_id FROM " . BB_CATEGORIES . " WHERE cat_title = '$name_sql'";
}
else
{
} else {
$what_checked = 'forum';
$sql = "SELECT forum_id FROM " . BB_FORUMS . " WHERE forum_name = '$name_sql'";
}
$name_is_dup = DB()->fetch_row($sql);
if ($name_is_dup && $die_on_error)
{
if ($name_is_dup && $die_on_error) {
bb_die('This ' . $what_checked . ' name taken, please choose something else');
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['GROUPS']['MANAGE'] = basename(__FILE__);
return;
}
@ -14,12 +36,9 @@ $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))
{
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(
@ -32,9 +51,7 @@ if (!empty($_POST['edit']) || !empty($_POST['new']))
);
$mode = 'editgroup';
$template->assign_block_vars('group_edit', array());
}
else if (!empty($_POST['new']))
{
} elseif (!empty($_POST['new'])) {
$group_info = array(
'group_name' => '',
'group_description' => '',
@ -70,13 +87,9 @@ if (!empty($_POST['edit']) || !empty($_POST['new']))
'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))
{
} 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
@ -87,27 +100,21 @@ else if (!empty($_POST['group_update']))
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
else
{
} 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 === '')
{
if ($group_name === '') {
bb_die($lang['NO_GROUP_NAME']);
}
else if ($group_moderator === '')
{
} elseif ($group_moderator === '') {
bb_die($lang['NO_GROUP_MODERATOR']);
}
$this_userdata = get_userdata($group_moderator, true);
if (!$group_moderator = $this_userdata['user_id'])
{
if (!$group_moderator = $this_userdata['user_id']) {
bb_die($lang['NO_GROUP_MODERATOR']);
}
@ -120,22 +127,18 @@ else if (!empty($_POST['group_update']))
'group_single_user' => 0,
);
if ($mode == "editgroup")
{
if (!$group_info = get_group_data($group_id))
{
if ($mode == "editgroup") {
if (!$group_info = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
if ($group_info['group_moderator'] != $group_moderator)
{
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']))
{
if (isset($_POST['delete_old_moderator'])) {
delete_user_group($group_id, $group_info['group_moderator']);
}
}
@ -150,9 +153,7 @@ else if (!empty($_POST['group_update']))
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
else if ($mode == 'newgroup')
{
} elseif ($mode == 'newgroup') {
$sql_ary['group_time'] = $sql_ary['mod_time'] = TIMENOW;
$sql_args = DB()->build_array('INSERT', $sql_ary);
@ -168,15 +169,11 @@ else if (!empty($_POST['group_update']))
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
bb_die($message);
}
else
{
} else {
bb_die($lang['NO_GROUP_ACTION']);
}
}
}
else
{
} else {
$template->assign_vars(array(
'TPL_GROUP_SELECT' => true,

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['USERS']['ACTIONS_LOG'] = basename(__FILE__);
return;
}
@ -51,8 +73,7 @@ $def_forums = $all_forums;
$def_sort = $sort_desc;
// Moderators data
if (!$mod = $datastore->get('moderators'))
{
if (!$mod = $datastore->get('moderators')) {
$datastore->update('moderators');
$mod = $datastore->get('moderators');
}
@ -64,8 +85,7 @@ $users = array($lang['ACTS_LOG_ALL_ACTIONS'] => $all_users) + array_flip($mod['m
unset($mod);
// Forums data
if (!$forums = $datastore->get('cat_forums'))
{
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
@ -80,12 +100,10 @@ $start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0;
$type_selected = array($def_types);
$type_csv = '';
if ($var =& $_REQUEST[$type_key])
{
if ($var =& $_REQUEST[$type_key]) {
$type_selected = get_id_ary($var);
if (in_array($all_types, $type_selected))
{
if (in_array($all_types, $type_selected)) {
$type_selected = array($all_types);
}
$type_csv = join(',', $type_selected);
@ -96,12 +114,10 @@ if ($var =& $_REQUEST[$type_key])
$user_selected = array($def_users);
$user_csv = '';
if ($var =& $_REQUEST[$user_key])
{
if ($var =& $_REQUEST[$user_key]) {
$user_selected = get_id_ary($var);
if (in_array($all_users, $user_selected))
{
if (in_array($all_users, $user_selected)) {
$user_selected = array($all_users);
}
$user_csv = join(',', $user_selected);
@ -112,12 +128,10 @@ if ($var =& $_REQUEST[$user_key])
$forum_selected = array($def_forums);
$forum_csv = '';
if ($var =& $_REQUEST[$forum_key])
{
if ($var =& $_REQUEST[$forum_key]) {
$forum_selected = get_id_ary($var);
if (in_array($all_forums, $forum_selected))
{
if (in_array($all_forums, $forum_selected)) {
$forum_selected = array($all_forums);
}
$forum_csv = join(',', $forum_selected);
@ -128,8 +142,7 @@ if ($var =& $_REQUEST[$forum_key])
$topic_selected = null;
$topic_csv = '';
if ($var =& $_REQUEST[$topic_key])
{
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;
@ -141,8 +154,7 @@ $order_val = 'log_time';
// Sort
$sort_val = $def_sort;
if ($var =& $_REQUEST[$sort_key] AND $var != $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);
}
@ -151,16 +163,13 @@ if ($var =& $_REQUEST[$sort_key] AND $var != $def_sort)
$datetime_val = $def_datetime;
$daysback_val = $def_days;
if ($var =& $_REQUEST[$daysback_key] AND $var != $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[$datetime_key] AND $var != $def_datetime)
{
if ($var =& $_REQUEST[$datetime_key] and $var != $def_datetime) {
$tz = TIMENOW + (3600 * $bb_cfg['board_timezone']);
if (($tmp_timestamp = strtotime($var, $tz)) > 0)
{
if (($tmp_timestamp = strtotime($var, $tz)) > 0) {
$datetime_val = $tmp_timestamp;
$url = url_arg($url, $datetime_key, date($dt_format, $datetime_val));
}
@ -176,10 +185,8 @@ $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))
{
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));
}
@ -229,14 +236,11 @@ $sql = "
$log_rowset = DB()->fetch_rowset($sql);
$log_count = count($log_rowset);
if ($log_count == $per_page + 1)
{
if ($log_count == $per_page + 1) {
$items_count = $start + ($per_page * 2);
$pages = '?';
array_pop($log_rowset);
}
else
{
} else {
$items_count = $start + $log_count;
$pages = (!$log_count) ? 1 : ceil($items_count / $per_page);
}
@ -245,21 +249,18 @@ generate_pagination($url, $items_count, $per_page, $start);
$filter = array();
if ($log_rowset)
{
if ($log_rowset) {
$log_type = $log_action->log_type;
$log_type_flip = array_flip($log_type);
foreach ($log_rowset as $row_num => $row)
{
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']);
switch ($row['log_type_id'])
{
switch ($row['log_type_id']) {
case $log_type['mod_topic_delete']:
case $log_type['mod_topic_move']:
case $log_type['mod_topic_lock']:
@ -267,23 +268,19 @@ if ($log_rowset)
case $log_type['mod_post_delete']:
case $log_type['mod_topic_split']:
// topic_title
if (!empty($row['log_topic_title']))
{
if (!empty($row['log_topic_title'])) {
$topic_title = $row['log_topic_title'];
}
// topic_title_new
if (!empty($row['log_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'])
{
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'])
{
if ($fid =& $row['log_forum_id_new']) {
$forum_name_new = ($fname =& $f_data[$fid]['forum_name']) ? $fname : 'id:' . $row['log_forum_id'];
}
@ -335,24 +332,21 @@ if ($log_rowset)
));
// Topics
if ($topic_csv && empty($filter['topics'][$row['log_topic_title']]))
{
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]))
{
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']]))
{
if ($user_csv && empty($filter['users'][$row['log_username']])) {
$template->assign_block_vars('users', array(
'USERNAME' => $row['log_username'],
));
@ -366,9 +360,7 @@ if ($log_rowset)
'FILTER_FORUMS' => !empty($filter['forums']),
'FILTER_USERS' => !empty($filter['users']),
));
}
else
{
} else {
$template->assign_block_vars('log_not_found', array());
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['MODS']['MASS_EMAIL'] = basename(__FILE__);
return;
}
@ -15,24 +37,26 @@ $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)
{
if (!$errors) {
$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
foreach ($sql as $row)
{
foreach ($sql as $row) {
$user_id_sql[] = ',' . $row['ban_userid'];
}
$user_id_sql = join('', $user_id_sql);
if ($group_id != -1)
{
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
@ -42,9 +66,7 @@ if (isset($_POST['submit']))
AND u.user_active = 1
AND u.user_id NOT IN(" . EXCLUDED_USERS_CSV . $user_id_sql . ")
");
}
else
{
} else {
$user_list = DB()->fetch_rowset("
SELECT username, user_email, user_lang
FROM " . BB_USERS . "
@ -55,8 +77,7 @@ if (isset($_POST['submit']))
require(CLASS_DIR . 'emailer.php');
foreach ($user_list as $i => $row)
{
foreach ($user_list as $i => $row) {
$emailer = new emailer($bb_cfg['smtp_delivery']);
$emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>");
@ -84,8 +105,7 @@ $sql = "SELECT group_id, group_name
";
$groups = array('-- ' . $lang['ALL_USERS'] . ' --' => -1);
foreach (DB()->fetch_rowset($sql) as $row)
{
foreach (DB()->fetch_rowset($sql) as $row) {
$groups[$row['group_name']] = $row['group_id'];
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['GENERAL']['PHP_INFO'] = basename(__FILE__);
return;
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['USERS']['RANKS'] = basename(__FILE__);
return;
}
@ -10,33 +32,23 @@ require('./pagestart.php');
$_POST['special_rank'] = 1;
$_POST['min_posts'] = -1;
if (isset($_GET['mode']) || isset($_POST['mode']))
{
if (isset($_GET['mode']) || isset($_POST['mode'])) {
$mode = isset($_GET['mode']) ? $_GET['mode'] : $_POST['mode'];
}
else
{
} else {
//
// These could be entered via a form button
//
if (isset($_POST['add']))
{
if (isset($_POST['add'])) {
$mode = 'add';
}
elseif (isset($_POST['save']))
{
} elseif (isset($_POST['save'])) {
$mode = 'save';
}
else
{
} else {
$mode = '';
}
}
if ($mode != '')
{
if ($mode == 'edit' || $mode == 'add')
{
if ($mode != '') {
if ($mode == 'edit' || $mode == 'add') {
//
// They want to add a new rank, show the form.
//
@ -44,24 +56,19 @@ if ($mode != '')
$s_hidden_fields = '';
if ($mode == 'edit')
{
if (empty($rank_id))
{
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))
{
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
{
} else {
$rank_info['rank_special'] = 0;
}
@ -84,9 +91,7 @@ if ($mode != '')
'S_RANK_ACTION' => "admin_ranks.php",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
elseif ($mode == 'save')
{
} elseif ($mode == 'save') {
//
// Ok, they sent us our info, let's update it.
//
@ -94,17 +99,15 @@ if ($mode != '')
$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;
$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 == '')
{
if ($rank_title == '') {
bb_die($lang['MUST_SELECT_RANK']);
}
if ($special_rank == 1)
{
if ($special_rank == 1) {
$max_posts = -1;
$min_posts = -1;
}
@ -112,21 +115,16 @@ if ($mode != '')
//
// The rank image has to be a jpg, gif or png
//
if ($rank_image != '')
{
if (!preg_match('/(\.gif|\.png|\.jpg)$/is', $rank_image))
{
if ($rank_image != '') {
if (!preg_match('/(\.gif|\.png|\.jpg)$/is', $rank_image)) {
$rank_image = '';
}
}
if ($rank_id)
{
if (!$special_rank)
{
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))
{
if (!$result = DB()->sql_query($sql)) {
bb_die($lang['NO_UPDATE_RANKS']);
}
}
@ -139,17 +137,14 @@ if ($mode != '')
WHERE rank_id = $rank_id";
$message = $lang['RANK_UPDATED'];
}
else
{
} 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'];
}
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not update / insert into ranks table');
}
@ -158,59 +153,44 @@ if ($mode != '')
$datastore->update('ranks');
bb_die($message);
}
elseif ($mode == 'delete')
{
} elseif ($mode == 'delete') {
//
// Ok, they want to delete their rank
//
if (isset($_POST['id']) || isset($_GET['id']))
{
if (isset($_POST['id']) || isset($_GET['id'])) {
$rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']);
}
else
{
} else {
$rank_id = 0;
}
if ($rank_id)
{
if ($rank_id) {
$sql = "DELETE FROM " . BB_RANKS . " WHERE rank_id = $rank_id";
if (!$result = DB()->sql_query($sql))
{
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))
{
if (!$result = DB()->sql_query($sql)) {
bb_die($lang['NO_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
{
} else {
bb_die($lang['MUST_SELECT_RANK']);
}
}
else
{
} else {
bb_die('Invalid mode');
}
}
else
{
} else {
//
// Show the default page
//
$sql = "SELECT * FROM " . BB_RANKS . " ORDER BY rank_min, rank_title";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain ranks data #2');
}
$rank_count = DB()->num_rows($result);
@ -221,15 +201,13 @@ else
'S_RANKS_ACTION' => "admin_ranks.php",
));
for ($i = 0; $i < $rank_count; $i++)
{
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)
{
if ($special_rank == 1) {
$rank_min = $rank_max = '-';
}

View file

@ -1,13 +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 (!empty($setmodules))
{
if (IS_SUPER_ADMIN) $module['GENERAL']['REBUILD_SEARCH_INDEX'] = basename(__FILE__);
if (!empty($setmodules)) {
if (IS_SUPER_ADMIN) {
$module['GENERAL']['REBUILD_SEARCH_INDEX'] = 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 . 'bbcode.php');
@ -30,11 +56,9 @@ $start_time = TIMENOW;
$mode = (string)@$_REQUEST['mode'];
// check if the user has choosen to stop processing
if (isset($_REQUEST['cancel_button']))
{
if (isset($_REQUEST['cancel_button'])) {
// update the rebuild_status
if ($last_session_id)
{
if ($last_session_id) {
DB()->query("
UPDATE " . BB_SEARCH_REBUILD . " SET
rebuild_session_status = " . REBUILD_SEARCH_ABORTED . "
@ -62,21 +86,16 @@ $session_posts_processed = ( $mode == 'refresh' ) ? get_processed_posts('session
$total_posts_processing = $total_posts - $total_posts_processed;
// how many posts to process in this session
if ($session_posts_processing = @intval($_REQUEST['session_posts_processing']))
{
if ($mode == 'submit')
{
if ($session_posts_processing = @intval($_REQUEST['session_posts_processing'])) {
if ($mode == 'submit') {
// check if we passed over total_posts just after submitting
if ($session_posts_processing + $total_posts_processed > $total_posts)
{
if ($session_posts_processing + $total_posts_processed > $total_posts) {
$session_posts_processing = $total_posts - $total_posts_processed;
}
}
// correct it when posts are deleted during processing
$session_posts_processing = ($session_posts_processing > $total_posts) ? $total_posts : $session_posts_processing;
}
else
{
} else {
// if we have finished, get all the posts, else only the remaining
$session_posts_processing = (!$total_posts_processing) ? $total_posts : $total_posts_processing;
}
@ -85,43 +104,35 @@ else
$post_limit = isset($_REQUEST['post_limit']) ? (int)$_REQUEST['post_limit'] : $def_post_limit;
// correct the post_limit when we pass over it
if ( $session_posts_processed + $post_limit > $session_posts_processing )
{
if ($session_posts_processed + $post_limit > $session_posts_processing) {
$post_limit = $session_posts_processing - $session_posts_processed;
}
// how much time to wait per cycle
if (isset($_REQUEST['time_limit']))
{
if (isset($_REQUEST['time_limit'])) {
$time_limit = (int)$_REQUEST['time_limit'];
}
else
{
} else {
$time_limit = $def_time_limit;
$time_limit_explain = $lang['TIME_LIMIT_EXPLAIN'];
// check for safe mode timeout
if ( ini_get('safe_mode') )
{
if (ini_get('safe_mode')) {
// get execution time
$max_execution_time = ini_get('max_execution_time');
$time_limit_explain .= '<br />' . sprintf($lang['TIME_LIMIT_EXPLAIN_SAFE'], $max_execution_time);
if ( $time_limit > $max_execution_time )
{
if ($time_limit > $max_execution_time) {
$time_limit = $max_execution_time;
}
}
// check for webserver timeout (IE returns null)
if ( isset($_SERVER["HTTP_KEEP_ALIVE"]) )
{
if (isset($_SERVER["HTTP_KEEP_ALIVE"])) {
// get webserver timeout
$webserver_timeout = intval($_SERVER["HTTP_KEEP_ALIVE"]);
$time_limit_explain .= '<br />' . sprintf($lang['TIME_LIMIT_EXPLAIN_WEBSERVER'], $webserver_timeout);
if ( $time_limit > $webserver_timeout )
{
if ($time_limit > $webserver_timeout) {
$time_limit = $webserver_timeout;
}
}
@ -131,10 +142,8 @@ else
$refresh_rate = isset($_REQUEST['refresh_rate']) ? (int)$_REQUEST['refresh_rate'] : $def_refresh_rate;
// check if the user gave wrong input
if ($mode == 'submit')
{
if (($session_posts_processing || $post_limit || $refresh_rate || $time_limit) <= 0)
{
if ($mode == 'submit') {
if (($session_posts_processing || $post_limit || $refresh_rate || $time_limit) <= 0) {
bb_die($lang['WRONG_INPUT'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_REBUILD_SEARCH'], '<a href="admin_rebuild_search.php">', '</a>'));
}
}
@ -143,11 +152,9 @@ if ($mode == 'submit')
@set_time_limit($time_limit + 20);
// check if we are should start processing
if ($mode == 'submit' || $mode == 'refresh')
{
if ($mode == 'submit' || $mode == 'refresh') {
// check if we are in the beginning of processing
if ($start == 0)
{
if ($start == 0) {
$last_session_data = get_empty_last_session_data();
clear_search_tables($clear_search);
}
@ -177,8 +184,7 @@ if ($mode == 'submit' || $mode == 'refresh')
$timer_expired = false;
$words_sql = array();
while ($row = DB()->fetch_next($result) AND !$timer_expired)
{
while ($row = DB()->fetch_next($result) and !$timer_expired) {
@set_time_limit(600);
$start_post_id = ($num_rows == 0) ? $row['post_id'] : $start_post_id;
$end_post_id = $row['post_id'];
@ -196,8 +202,7 @@ if ($mode == 'submit' || $mode == 'refresh')
}
// Store search words
if ($words_sql)
{
if ($words_sql) {
DB()->query("REPLACE INTO " . BB_POSTS_SEARCH . DB()->build_array('MULTI_INSERT', $words_sql));
}
@ -205,10 +210,8 @@ if ($mode == 'submit' || $mode == 'refresh')
$last_cycle_time = intval(TIMENOW - $start_time);
// check if we had any data
if ($num_rows != 0)
{
if ($mode == 'submit')
{
if ($num_rows != 0) {
if ($mode == 'submit') {
// insert a new session entry
$args = DB()->build_array('INSERT', array(
'end_post_id' => (int)$end_post_id,
@ -223,9 +226,9 @@ if ($mode == 'submit' || $mode == 'refresh')
'rebuild_session_status' => REBUILD_SEARCH_PROCESSED,
));
DB()->query("REPLACE INTO " . BB_SEARCH_REBUILD . $args);
}
else // refresh
{
} else {
// refresh
// update the last session entry
DB()->query("
UPDATE " . BB_SEARCH_REBUILD . " SET
@ -253,8 +256,7 @@ if ($mode == 'submit' || $mode == 'refresh')
$total_posts_processed = get_total_posts('before', $last_session_data['end_post_id']);
$total_posts = get_total_posts();
if ( $session_posts_processed < $session_posts_processing && $total_posts_processed < $total_posts )
{
if ($session_posts_processed < $session_posts_processing && $total_posts_processed < $total_posts) {
$form_parameters = '&start=' . ($end_post_id + 1);
$form_parameters .= '&session_posts_processing=' . $session_posts_processing;
$form_parameters .= '&post_limit=' . $post_limit;
@ -273,9 +275,9 @@ if ($mode == 'submit' || $mode == 'refresh')
$template->assign_vars(array(
'CANCEL_BUTTON' => true,
));
}
else // end of processing
{
} else {
// end of processing
$form_action = "admin_rebuild_search.php";
$next_button = $lang['FINISHED'];
$progress_bar_img = $images['progress_bar_full'];
@ -293,8 +295,7 @@ if ($mode == 'submit' || $mode == 'refresh')
// optimize all search tables when finished
$table_ary = array(BB_POSTS_SEARCH);
foreach ($table_ary as $table)
{
foreach ($table_ary as $table) {
DB()->query("ANALYZE TABLE $table");
DB()->query("OPTIMIZE TABLE $table");
}
@ -312,8 +313,7 @@ if ($mode == 'submit' || $mode == 'refresh')
// calculate the final (estimated) values
$final_search_tables_size = '';
if ($search_tables_size)
{
if ($search_tables_size) {
$start_search_tables_size = $last_session_data['search_size'];
$final_search_tables_size = $start_search_tables_size + round(($search_tables_size - $start_search_tables_size) * (100 / $session_percent));
}
@ -358,9 +358,7 @@ if ($mode == 'submit' || $mode == 'refresh')
'S_REBUILD_SEARCH_ACTION' => $form_action,
));
}
else // show the input page
{
} else {// show the input page
// create the page
// used only with the select input
$post_limit_hidden = ($def_post_limit > $total_posts) ? $total_posts : $def_post_limit;
@ -372,43 +370,35 @@ else // show the input page
$last_saved_processing = '';
$clear_search_disabled = '';
if ($last_session_data['rebuild_session_id'])
{
if ($last_session_data['rebuild_session_id']) {
$last_saved_post_id = $last_session_data['end_post_id'];
$next_start_post_id = $last_saved_post_id + 1;
$last_saved_date = bb_date($last_session_data['end_time']);
// check our last status
if ( $last_session_data['rebuild_session_status'] == REBUILD_SEARCH_PROCESSED )
{
if ($last_session_data['rebuild_session_status'] == REBUILD_SEARCH_PROCESSED) {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_STOPPED'], $last_saved_post_id, $total_posts_processed, $last_saved_date);
$clear_search_disabled = 'disabled="disabled"';
$template->assign_block_vars("start_select_input", array());
}
elseif ( $last_session_data['rebuild_session_status'] == REBUILD_SEARCH_ABORTED )
{
} elseif ($last_session_data['rebuild_session_status'] == REBUILD_SEARCH_ABORTED) {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_ABORTED'], $last_saved_post_id, $total_posts_processed, $last_saved_date);
// check if the interrupted cycle has finished
if ( TIMENOW - $last_session_data['end_time'] < $last_session_data['last_cycle_time'] )
{
if (TIMENOW - $last_session_data['end_time'] < $last_session_data['last_cycle_time']) {
$last_saved_processing .= '<br />' . $lang['INFO_PROCESSING_ABORTED_SOON'];
}
$clear_search_disabled = 'disabled="disabled"';
$template->assign_block_vars("start_select_input", array());
}
else // when finished
{
if ( $last_session_data['end_post_id'] < $max_post_id )
{
} else {
// when finished
if ($last_session_data['end_post_id'] < $max_post_id) {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_FINISHED_NEW'], $last_saved_post_id, $total_posts_processed, $last_saved_date, ($total_posts - $total_posts_processed));
$clear_search_disabled = 'disabled="disabled"';
$template->assign_block_vars("start_select_input", array());
}
else
{
} else {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_FINISHED'], $total_posts, $last_saved_date);
$template->assign_block_vars("start_text_input", array());
@ -416,9 +406,7 @@ else // show the input page
}
$template->assign_block_vars("last_saved_info", array());
}
else
{
} else {
$template->assign_block_vars("start_text_input", array());
}
@ -456,8 +444,7 @@ function get_db_sizes ()
$sql = "SHOW TABLE STATUS FROM `" . DB()->selected_db . "` LIKE '$search_table_like'";
foreach (DB()->fetch_rowset($sql) as $row)
{
foreach (DB()->fetch_rowset($sql) as $row) {
$search_data_size += $row['Data_length'];
$search_index_size += $row['Index_length'];
}
@ -497,17 +484,13 @@ function get_rebuild_session_details ($id, $details = 'all')
{
$session_details = get_empty_last_session_data();
if ($id != 'last')
{
if ($id != 'last') {
$sql = "SELECT * FROM " . BB_SEARCH_REBUILD . " WHERE rebuild_session_id = $id";
}
else
{
} else {
$sql = "SELECT * FROM " . BB_SEARCH_REBUILD . " ORDER BY rebuild_session_id DESC LIMIT 1";
}
if ($row = DB()->fetch_row($sql))
{
if ($row = DB()->fetch_row($sql)) {
$session_details = ($details == 'all') ? $row : $row[$details];
}
@ -521,13 +504,10 @@ function get_processed_posts ($mode = 'session')
{
global $last_session_data;
if ($mode == 'total')
{
if ($mode == 'total') {
$sql = "SELECT SUM(session_posts) as posts FROM " . BB_SEARCH_REBUILD;
$row = DB()->fetch_row($sql);
}
else
{
} else {
$row['posts'] = $last_session_data['session_posts'];
}
@ -538,13 +518,10 @@ function get_processed_posts ($mode = 'session')
// after/before require and the post_id
function get_total_posts($mode = 'after', $post_id = 0)
{
if ($post_id)
{
if ($post_id) {
$sql = "SELECT COUNT(post_id) as total_posts FROM " . BB_POSTS_TEXT . "
WHERE post_id " . (($mode == 'after') ? '>= ' : '<= ') . (int)$post_id;
}
else
{
} else {
$sql = "SELECT COUNT(*) as total_posts FROM " . BB_POSTS_TEXT;
}
@ -557,12 +534,10 @@ function clear_search_tables ($mode = '')
{
DB()->query("DELETE FROM " . BB_SEARCH_REBUILD);
if ($mode)
{
if ($mode) {
$table_ary = array(BB_POSTS_SEARCH);
foreach ($table_ary as $table)
{
foreach ($table_ary as $table) {
$sql = (($mode == 1) ? "DELETE FROM " : "TRUNCATE TABLE ") . $table;
DB()->query($sql);
}
@ -582,10 +557,8 @@ function create_percent_color($percent)
'b' => array(51, 85),
);
foreach ($percent_ary as $key => $value)
{
if ( $percent <= $value[1] )
{
foreach ($percent_ary as $key => $value) {
if ($percent <= $value[1]) {
$percent_color = create_color($key, round(200 - ($percent - $value[0]) * (200 / ($value[1] - $value[0]))));
break;
}
@ -605,16 +578,13 @@ function create_percent_box($box, $percent_color, $percent_width)
{
global $template;
if ($box == 'session')
{
if ($box == 'session') {
$template->assign_vars(array(
'SESSION_PERCENT_BOX' => true,
'SESSION_PERCENT_COLOR' => $percent_color,
'SESSION_PERCENT_WIDTH' => round($percent_width),
));
}
else
{
} else {
$template->assign_vars(array(
'TOTAL_PERCENT_BOX' => true,
'TOTAL_PERCENT_COLOR' => $percent_color,

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['MODS']['SITEMAP'] = basename(__FILE__);
return;
}
@ -11,31 +33,24 @@ require(INC_DIR .'functions_selects.php');
$sql = "SELECT * FROM " . BB_CONFIG;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query config information in admin_sitemap');
}
else
{
} else {
$new_params = array();
while ($row = DB()->sql_fetchrow($result))
{
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])
{
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))
{
if (isset($_POST['submit'])) {
if (!empty($new_params)) {
bb_update_config($new_params);
}
}

View file

@ -1,20 +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 (!empty($setmodules))
{
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']))
{
if (isset($_POST['mode']) || isset($_GET['mode'])) {
$mode = (isset($_POST['mode'])) ? $_POST['mode'] : $_GET['mode'];
$mode = htmlspecialchars($mode);
}
else
{
} else {
$mode = '';
}
@ -23,18 +42,13 @@ $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)))
{
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])
{
if ($img_size[0] && $img_size[1]) {
$smiley_images[] = $file;
}
else if (preg_match('/.pak$/i', $file))
{
} elseif (preg_match('/.pak$/i', $file)) {
$smiley_paks[] = $file;
}
}
@ -43,36 +57,28 @@ while ($file = @readdir($dir))
@closedir($dir);
// Select main mode
if (isset($_GET['import_pack']) || isset($_POST['import_pack']))
{
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))
{
if (!empty($smile_pak)) {
// The user has already selected a smile_pak file.. Import it
if (!empty($clear_current))
{
if (!empty($clear_current)) {
$sql = "DELETE FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not delete current smilies');
}
$datastore->update('smile_replacements');
}
else
{
} else {
$sql = "SELECT code FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get current smilies');
}
$cur_smilies = DB()->sql_fetchrowset($result);
for ($i = 0; $i < count($cur_smilies); $i++)
{
for ($i = 0; $i < count($cur_smilies); $i++) {
$k = $cur_smilies[$i]['code'];
$smiles[$k] = 1;
}
@ -80,46 +86,35 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack']))
$fcontents = @file(BB_ROOT . $bb_cfg['smilies_path'] . '/' . $smile_pak);
if (empty($fcontents))
{
if (empty($fcontents)) {
bb_die('Could not read smiley pak file');
}
for ($i = 0; $i < count($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++)
{
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) )
{
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
{
} else {
$sql = '';
}
}
else
{
} 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 != '')
{
if ($sql != '') {
$result = DB()->sql_query($sql);
if (!$result)
{
if (!$result) {
bb_die('Could not update smilies #1');
}
$datastore->update('smile_replacements');
@ -128,15 +123,11 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack']))
}
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
{
} 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))
{
while (list($key, $value) = @each($smiley_paks)) {
if (!empty($value)) {
$smile_paks_select .= '<option>' . $value . '</option>';
}
}
@ -152,24 +143,19 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack']))
'S_HIDDEN_FIELDS' => $hidden_vars,
));
}
}
else if (isset($_POST['export_pack']) || isset($_GET['export_pack']))
{
} elseif (isset($_POST['export_pack']) || isset($_GET['export_pack'])) {
$export_pack = (string)request_var('export_pack', '');
if ($export_pack == 'send')
{
if ($export_pack == 'send') {
$sql = "SELECT * FROM " . BB_SMILIES;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not get smiley list');
}
$resultset = DB()->sql_fetchrowset($result);
$smile_pak = '';
for ($i = 0; $i < count($resultset); $i++)
{
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";
@ -184,12 +170,9 @@ else if (isset($_POST['export_pack']) || isset($_GET['export_pack']))
}
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']))
{
} elseif (isset($_POST['add']) || isset($_GET['add'])) {
$filename_list = '';
for ($i = 0; $i < count($smiley_images); $i++)
{
for ($i = 0; $i < count($smiley_images); $i++) {
$filename_list .= '<option value="' . $smiley_images[$i] . '">' . $smiley_images[$i] . '</option>';
}
@ -203,19 +186,15 @@ else if (isset($_POST['add']) || isset($_GET['add']))
'S_FILENAME_OPTIONS' => $filename_list,
'S_SMILEY_BASEDIR' => BB_ROOT . $bb_cfg['smilies_path']
));
}
else if ( $mode != '' )
{
switch( $mode )
{
} 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)
{
if (!$result) {
bb_die('Could not delete smiley');
}
$datastore->update('smile_replacements');
@ -229,22 +208,17 @@ else if ( $mode != '' )
$sql = "SELECT * FROM " . BB_SMILIES . " WHERE smilies_id = " . $smiley_id;
$result = DB()->sql_query($sql);
if (!$result)
{
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'])
{
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
{
} else {
$smiley_selected = '';
}
$filename_list .= '<option value="' . $smiley_images[$i] . '"' . $smiley_selected . '>' . $smiley_images[$i] . '</option>';
@ -273,8 +247,7 @@ else if ( $mode != '' )
$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 == '')
{
if ($smile_code == '' || $smile_url == '') {
bb_die($lang['FIELDS_EMPTY']);
}
@ -286,8 +259,7 @@ else if ( $mode != '' )
$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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not update smilies #2');
}
$datastore->update('smile_replacements');
@ -305,8 +277,7 @@ else if ( $mode != '' )
$smile_emotion = trim($smile_emotion);
// If no code was entered complain
if ($smile_code == '' || $smile_url == '')
{
if ($smile_code == '' || $smile_url == '') {
bb_die($lang['FIELDS_EMPTY']);
}
@ -318,8 +289,7 @@ else if ( $mode != '' )
$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)
{
if (!$result) {
bb_die('Could not insert new smiley');
}
$datastore->update('smile_replacements');
@ -327,13 +297,10 @@ else if ( $mode != '' )
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
{
} else {
$sql = "SELECT * FROM " . BB_SMILIES;
$result = DB()->sql_query($sql);
if (!$result)
{
if (!$result) {
bb_die('Could not obtain smileys from database');
}
@ -346,8 +313,7 @@ else
));
// Loop throuh the rows of smilies setting block vars for the template
for ($i = 0; $i < count($smilies); $i++)
{
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']);

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['GENERAL']['TERMS'] = basename(__FILE__);
return;
}
@ -9,8 +31,7 @@ require('./pagestart.php');
require(INC_DIR . 'bbcode.php');
if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message'])
{
if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message']) {
bb_update_config(array('terms' => $_POST['message']));
bb_die($lang['CONFIG_UPDATED']);
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['USERS']['PERMISSIONS'] = basename(__FILE__) . '?mode=user';
$module['GROUPS']['PERMISSIONS'] = basename(__FILE__) . '?mode=group';
return;
@ -38,13 +60,11 @@ $forum_auth_fields = array(
'auth_announce',
);
if ($submit && $mode == 'user')
{
if ($submit && $mode == 'user') {
$this_user_level = null;
// Obtain relevant data for this user
if (!$row = get_userdata($user_id))
{
if (!$row = get_userdata($user_id)) {
bb_die($lang['NO_SUCH_USER']);
}
$this_user_level = $row['user_level'];
@ -56,25 +76,19 @@ if ($submit && $mode == 'user')
AND g.group_id = ug.group_id
AND g.group_single_user = 1";
if ($row = DB()->fetch_row($sql))
{
if ($row = DB()->fetch_row($sql)) {
$group_id = $row['group_id'];
}
else
{
} else {
$group_id = create_user_group($user_id);
}
if (!$group_id || !$user_id || is_null($this_user_level))
{
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)
{
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");
}
@ -88,13 +102,10 @@ if ($submit && $mode == 'user')
$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')
{
} // 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)
{
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
@ -114,14 +125,11 @@ if ($submit && $mode == 'user')
//
$auth = array();
if (is_array(@$_POST['auth']))
{
if (is_array(@$_POST['auth'])) {
array_deep($_POST['auth'], 'intval');
foreach ($_POST['auth'] as $f_id => $bf_ary)
{
if (array_sum($bf_ary))
{
foreach ($_POST['auth'] as $f_id => $bf_ary) {
if (array_sum($bf_ary)) {
$auth[$f_id] = bit2dec(array_keys($bf_ary, 1));
}
}
@ -142,20 +150,16 @@ if ($submit && $mode == 'user')
//
// Submit new GROUP permissions
//
else if ($submit && $mode == 'group' && is_array(@$_POST['auth']))
{
if (!$group_data = get_group_data($group_id))
{
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');
foreach ($_POST['auth'] as $f_id => $bf_ary)
{
if (array_sum($bf_ary))
{
foreach ($_POST['auth'] as $f_id => $bf_ary) {
if (array_sum($bf_ary)) {
$auth[$f_id] = bit2dec(array_keys($bf_ary, 1));
}
}
@ -176,26 +180,20 @@ else if ($submit && $mode == 'group' && is_array(@$_POST['auth']))
//
// Front end (changing permissions)
//
if ($mode == 'user' && (!empty($_POST['username']) || $user_id))
{
if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) {
$page_cfg['quirks_mode'] = true;
if (!empty($_POST['username']))
{
if (!empty($_POST['username'])) {
$this_userdata = get_userdata($_POST['username'], true);
$user_id = $this_userdata['user_id'];
}
else
{
} else {
$this_userdata = get_userdata($user_id);
}
if (!$this_userdata)
{
if (!$this_userdata) {
bb_die($lang['NO_SUCH_USER']);
}
if (!$forums = $datastore->get('cat_forums'))
{
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
@ -207,21 +205,18 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id))
$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)
{
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']))
{
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)
{
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'];
@ -237,20 +232,16 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id))
'AUTH_MOD_VAL' => ($auth_mod) ? 1 : 0,
));
foreach ($forum_auth_fields as $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)
{
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
{
} else {
$disabled = true;
$perm_sign = ($auth_via_acl) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl) ? 'yes' : 'no';
@ -274,8 +265,7 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id))
$s_column_span = 2;
foreach ($forum_auth_fields as $auth_type)
{
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],
@ -321,18 +311,14 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id))
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else if ($mode == 'group' && $group_id)
{
} elseif ($mode == 'group' && $group_id) {
$page_cfg['quirks_mode'] = true;
if (!$group_data = get_group_data($group_id))
{
if (!$group_data = get_group_data($group_id)) {
bb_die($lang['GROUP_NOT_EXIST']);
}
if (!$forums = $datastore->get('cat_forums'))
{
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
@ -341,21 +327,18 @@ else if ($mode == 'group' && $group_id)
$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)
{
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']))
{
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)
{
foreach ($c_data['forums'] as $f_id) {
$f_data = $forums['f'][$f_id];
$auth_mod = $u_access[$f_id]['auth_mod'];
@ -370,20 +353,16 @@ else if ($mode == 'group' && $group_id)
'AUTH_MOD_VAL' => ($auth_mod) ? 1 : 0,
));
foreach ($forum_auth_fields as $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)
{
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
{
} else {
$disabled = true;
$perm_sign = ($auth_via_acl) ? $yes_sign : $no_sign;
$acl_class = ($auth_via_acl) ? 'yes' : 'no';
@ -407,8 +386,7 @@ else if ($mode == 'group' && $group_id)
$s_column_span = 2;
foreach ($forum_auth_fields as $auth_type)
{
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],
@ -435,19 +413,14 @@ else if ($mode == 'group' && $group_id)
'S_COLUMN_SPAN' => $s_column_span,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else
{
} else {
// Select a user/group
if ($mode == 'user')
{
if ($mode == 'user') {
$template->assign_vars(array(
'TPL_SELECT_USER' => true,
'U_SEARCH_USER' => BB_ROOT . "search.php?mode=searchuser",
));
}
else
{
} else {
$template->assign_vars(array(
'TPL_SELECT_GROUP' => true,
'S_GROUP_SELECT' => get_select('groups'),

View file

@ -1,24 +1,43 @@
<?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 (!empty($setmodules)) {
$module['USERS']['BAN_MANAGEMENT'] = basename(__FILE__);
return;
}
require('./pagestart.php');
if (isset($_POST['submit']))
{
if (isset($_POST['submit'])) {
$user_bansql = '';
$email_bansql = '';
$ip_bansql = '';
$user_list = array();
if (!empty($_POST['username']))
{
if (!empty($_POST['username'])) {
$this_userdata = get_userdata($_POST['username'], true);
if (!$this_userdata)
{
if (!$this_userdata) {
bb_die($lang['NO_USER_ID_SPECIFIED']);
}
@ -26,58 +45,48 @@ if (isset($_POST['submit']))
}
$ip_list = array();
if (isset($_POST['ban_ip']))
{
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))
{
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 )
{
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 )
{
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");
}
while ( $ip_2_counter <= $ip_2_end )
{
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 )
{
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");
}
while ( $ip_3_counter <= $ip_3_end )
{
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 )
{
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");
}
while ( $ip_4_counter <= $ip_4_end )
{
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++;
}
@ -87,43 +96,33 @@ if (isset($_POST['submit']))
}
$ip_1_counter++;
}
}
else if (preg_match('/^([\w\-_]\.?){2,}$/is', trim($ip_list_temp[$i])))
{
} 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]))
{
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])))
{
} 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']))
{
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])))
{
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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain banlist information');
}
@ -131,87 +130,67 @@ if (isset($_POST['submit']))
DB()->sql_freeresult($result);
$kill_session_sql = '';
for ($i = 0; $i < count($user_list); $i++)
{
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'])
{
for ($j = 0; $j < count($current_banlist); $j++) {
if ($user_list[$i] == $current_banlist[$j]['ban_userid']) {
$in_banlist = true;
}
}
if (!$in_banlist)
{
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))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_userid info into database');
}
}
}
for ($i = 0; $i < count($ip_list); $i++)
{
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'])
{
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, '.')))
{
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
{
} else {
$kill_ip_sql = "session_ip = '" . $ip_list[$i] . "'";
}
$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) )
{
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 != '')
{
if ($kill_session_sql != '') {
$sql = "DELETE FROM " . BB_SESSIONS . " WHERE $kill_session_sql";
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not delete banned sessions from database');
}
}
for ($i = 0; $i < count($email_list); $i++)
{
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'])
{
for ($j = 0; $j < count($current_banlist); $j++) {
if ($email_list[$i] == $current_banlist[$j]['ban_email']) {
$in_banlist = true;
}
}
if (!$in_banlist)
{
if (!$in_banlist) {
$sql = "INSERT INTO " . BB_BANLIST . " (ban_email) VALUES ('" . DB()->escape($email_list[$i]) . "')";
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_email info into database');
}
}
@ -219,58 +198,45 @@ if (isset($_POST['submit']))
$where_sql = '';
if (isset($_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)
{
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']))
{
if (isset($_POST['unban_ip'])) {
$ip_list = $_POST['unban_ip'];
for ($i = 0; $i < count($ip_list); $i++)
{
if ($ip_list[$i] != -1)
{
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']))
{
if (isset($_POST['unban_email'])) {
$email_list = $_POST['unban_email'];
for ($i = 0; $i < count($email_list); $i++)
{
if ($email_list[$i] != -1)
{
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 != '')
{
if ($where_sql != '') {
$sql = "DELETE FROM " . BB_BANLIST . " WHERE ban_id IN ($where_sql)";
if (!DB()->sql_query($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
{
} else {
$template->assign_vars(array(
'S_BANLIST_ACTION' => 'admin_user_ban.php',
));
@ -285,8 +251,7 @@ else
AND b.ban_userid <> 0
AND u.user_id <> " . GUEST_UID . "
ORDER BY u.username ASC";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select current user_id ban list');
}
@ -294,22 +259,19 @@ else
DB()->sql_freeresult($result);
$select_userlist = '';
for ($i = 0; $i < count($user_list); $i++)
{
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 == '')
{
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>';
$sql = "SELECT ban_id, ban_ip, ban_email FROM " . BB_BANLIST . " ORDER BY ban_ip";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select current ip ban list');
}
@ -319,31 +281,25 @@ else
$select_iplist = '';
$select_emaillist = '';
for ($i = 0; $i < count($banlist); $i++)
{
for ($i = 0; $i < count($banlist); $i++) {
$ban_id = $banlist[$i]['ban_id'];
if (!empty($banlist[$i]['ban_ip']))
{
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']))
{
} 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 == '')
{
if ($select_iplist == '') {
$select_iplist = '<option value="-1">' . $lang['NO_BANNED_IP'] . '</option>';
}
if ($select_emaillist == '')
{
if ($select_emaillist == '') {
$select_emaillist = '<option value="-1">' . $lang['NO_BANNED_EMAIL'] . '</option>';
}

View file

@ -1,7 +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.
*/
if (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['USERS']['SEARCH'] = basename(__FILE__);
return;
}
@ -13,41 +35,34 @@ require(INC_DIR .'functions_selects.php');
$total_sql = '';
if (!isset($_REQUEST['dosearch']))
{
if (!isset($_REQUEST['dosearch'])) {
$sql = "SELECT group_id, group_name
FROM " . BB_GROUPS . "
WHERE group_single_user = 0
ORDER BY group_name ASC";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not select group data #1');
}
$group_list = '';
if (DB()->num_rows($result) != 0)
{
if (DB()->num_rows($result) != 0) {
$template->assign_block_vars('groups_exist', array());
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$group_list .= '<option value="' . $row['group_id'] . '">' . strip_tags(htmlspecialchars($row['group_name'])) . '</option>';
}
}
$sql = "SELECT * FROM " . BB_RANKS . " WHERE rank_special = 1 ORDER BY rank_title";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not obtain ranks data');
}
$rank_select_box = '';
if (DB()->num_rows($result) != 0)
{
if (DB()->num_rows($result) != 0) {
$template->assign_block_vars('ranks_exist', array());
while( $row = DB()->sql_fetchrow($result) )
{
while ($row = DB()->sql_fetchrow($result)) {
$rank = $row['rank_title'];
$rank_id = $row['rank_id'];
$rank_select_box .= '<option value="' . $rank_id . '">' . $rank . '</option>';
@ -61,24 +76,20 @@ if (!isset($_REQUEST['dosearch']))
FROM ( " . BB_FORUMS . " AS f INNER JOIN " . BB_CATEGORIES . " AS c ON c.cat_id = f.cat_id )
ORDER BY c.cat_order, f.forum_order ASC";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not select forum data');
}
$forums = array();
if (DB()->num_rows($result) != 0)
{
if (DB()->num_rows($result) != 0) {
$template->assign_block_vars('forums_exist', array());
$last_cat_id = -1;
$forums_list = '';
while ($row = DB()->sql_fetchrow($result))
{
if ($row['cat_id'] != $last_cat_id)
{
while ($row = DB()->sql_fetchrow($result)) {
if ($row['cat_id'] != $last_cat_id) {
$forums_list .= '<optgroup label="' . htmlCHR($row['cat_title']) . '">';
$last_cat_id = $row['cat_id'];
}
@ -90,8 +101,7 @@ if (!isset($_REQUEST['dosearch']))
$lastvisited = array(1, 7, 14, 30, 60, 120, 365, 500, 730, 1000);
$lastvisited_list = '';
foreach ($lastvisited as $days)
{
foreach ($lastvisited as $days) {
$lastvisited_list .= '<option value="' . $days . '">' . $days . ' ' . (($days > 1) ? $lang['DAYS'] : $lang['DAY']) . '</option>';
}
@ -110,81 +120,59 @@ if (!isset($_REQUEST['dosearch']))
'S_SEARCH_ACTION' => 'admin_user_search.php',
));
}
else
{
} else {
$mode = '';
// validate mode
if (isset($_REQUEST['search_username']))
{
if (isset($_REQUEST['search_username'])) {
$mode = 'search_username';
}
elseif (isset($_REQUEST['search_email']))
{
} elseif (isset($_REQUEST['search_email'])) {
$mode = 'search_email';
}
elseif (isset($_REQUEST['search_ip']))
{
} elseif (isset($_REQUEST['search_ip'])) {
$mode = 'search_ip';
}
elseif (isset($_REQUEST['search_joindate']))
{
} elseif (isset($_REQUEST['search_joindate'])) {
$mode = 'search_joindate';
}
elseif (isset($_REQUEST['search_group']))
{
} elseif (isset($_REQUEST['search_group'])) {
$mode = 'search_group';
}
elseif (isset($_REQUEST['search_rank']))
{
} elseif (isset($_REQUEST['search_rank'])) {
$mode = 'search_rank';
}
elseif (isset($_REQUEST['search_postcount']))
{
} elseif (isset($_REQUEST['search_postcount'])) {
$mode = 'search_postcount';
}
elseif (isset($_REQUEST['search_userfield']))
{
} elseif (isset($_REQUEST['search_userfield'])) {
$mode = 'search_userfield';
}
elseif (isset($_REQUEST['search_lastvisited']))
{
} elseif (isset($_REQUEST['search_lastvisited'])) {
$mode = 'search_lastvisited';
}
elseif (isset($_REQUEST['search_language']))
{
} elseif (isset($_REQUEST['search_language'])) {
$mode = 'search_language';
}
elseif (isset($_REQUEST['search_timezone']))
{
} elseif (isset($_REQUEST['search_timezone'])) {
$mode = 'search_timezone';
}
elseif (isset($_REQUEST['search_moderators']))
{
} elseif (isset($_REQUEST['search_moderators'])) {
$mode = 'search_moderators';
}
elseif (isset($_REQUEST['search_misc']))
{
} elseif (isset($_REQUEST['search_misc'])) {
$mode = 'search_misc';
}
// validate fields (that they exist)
switch ($mode)
{
switch ($mode) {
case 'search_username':
$username = $_REQUEST['username'];
if (!$username) bb_die($lang['SEARCH_INVALID_USERNAME']);
if (!$username) {
bb_die($lang['SEARCH_INVALID_USERNAME']);
}
break;
case 'search_email':
$email = $_REQUEST['email'];
if (!$email) bb_die($lang['SEARCH_INVALID_EMAIL']);
if (!$email) {
bb_die($lang['SEARCH_INVALID_EMAIL']);
}
break;
case 'search_ip':
$ip_address = $_REQUEST['ip_address'];
if (!$ip_address) bb_die($lang['SEARCH_INVALID_IP']);
if (!$ip_address) {
bb_die($lang['SEARCH_INVALID_IP']);
}
break;
case 'search_joindate':
@ -192,55 +180,75 @@ else
$date_day = $_REQUEST['date_day'];
$date_month = $_REQUEST['date_month'];
$date_year = $_REQUEST['date_year'];
if (!($date_type || $date_day || $date_month || $date_year)) bb_die($lang['SEARCH_INVALID_DATE']);
if (!($date_type || $date_day || $date_month || $date_year)) {
bb_die($lang['SEARCH_INVALID_DATE']);
}
break;
case 'search_group':
$group_id = $_REQUEST['group_id'];
if (!$group_id) bb_die($lang['SEARCH_INVALID_GROUP']);
if (!$group_id) {
bb_die($lang['SEARCH_INVALID_GROUP']);
}
break;
case 'search_rank':
$rank_id = $_REQUEST['rank_id'];
if (!$rank_id) bb_die($lang['SEARCH_INVALID_RANK']);
if (!$rank_id) {
bb_die($lang['SEARCH_INVALID_RANK']);
}
break;
case 'search_postcount':
$postcount_type = $_REQUEST['postcount_type'];
$postcount_value = $_REQUEST['postcount_value'];
if (!$postcount_type || (!$postcount_value && $postcount_value != 0)) bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
if (!$postcount_type || (!$postcount_value && $postcount_value != 0)) {
bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
}
break;
case 'search_userfield':
$userfield_type = $_REQUEST['userfield_type'];
$userfield_value = $_REQUEST['userfield_value'];
if (!$userfield_type || !$userfield_value) bb_die($lang['SEARCH_INVALID_USERFIELD']);
if (!$userfield_type || !$userfield_value) {
bb_die($lang['SEARCH_INVALID_USERFIELD']);
}
break;
case 'search_lastvisited':
$lastvisited_days = $_REQUEST['lastvisited_days'];
$lastvisited_type = $_REQUEST['lastvisited_type'];
if (!$lastvisited_days || !$lastvisited_type) bb_die($lang['SEARCH_INVALID_LASTVISITED']);
if (!$lastvisited_days || !$lastvisited_type) {
bb_die($lang['SEARCH_INVALID_LASTVISITED']);
}
break;
case 'search_language':
$language_type = $_REQUEST['language_type'];
if (!$language_type) bb_die($lang['SEARCH_INVALID_LANGUAGE']);
if (!$language_type) {
bb_die($lang['SEARCH_INVALID_LANGUAGE']);
}
break;
case 'search_timezone':
$timezone_type = $_REQUEST['timezone_type'];
if (!$timezone_type && $timezone_type != 0) bb_die($lang['SEARCH_INVALID_TIMEZONE']);
if (!$timezone_type && $timezone_type != 0) {
bb_die($lang['SEARCH_INVALID_TIMEZONE']);
}
break;
case 'search_moderators':
$moderators_forum = $_REQUEST['moderators_forum'];
if (!$moderators_forum) bb_die($lang['SEARCH_INVALID_MODERATORS']);
if (!$moderators_forum) {
bb_die($lang['SEARCH_INVALID_MODERATORS']);
}
break;
case 'search_misc':
$misc = $_REQUEST['misc'];
if (!$misc) bb_die($lang['SEARCH_INVALID']);
if (!$misc) {
bb_die($lang['SEARCH_INVALID']);
}
break;
default:
@ -255,8 +263,7 @@ else
$lower_e = ')';
// validate data & prepare sql
switch($mode)
{
switch ($mode) {
case 'search_username':
$base_url .= '&search_username=true&username=' . rawurlencode(stripslashes($username));
@ -264,16 +271,15 @@ else
$username = preg_replace('/\*/', '%', trim(strip_tags(strtolower($username))));
if (strstr($username, '%'))
{
if (strstr($username, '%')) {
$op = 'LIKE';
}
else
{
} else {
$op = '=';
}
if ($username == '') bb_die($lang['SEARCH_INVALID_USERNAME']);
if ($username == '') {
bb_die($lang['SEARCH_INVALID_USERNAME']);
}
$total_sql .= "SELECT COUNT(user_id) AS total FROM " . BB_USERS . " WHERE {$lower_b}username{$lower_e} $op '" . DB()->escape($username) . "' AND user_id <> " . GUEST_UID;
$select_sql .= " WHERE {$lower_b}u.username{$lower_e} $op '" . DB()->escape($username) . "' AND u.user_id <> " . GUEST_UID;
@ -286,16 +292,15 @@ else
$email = preg_replace('/\*/', '%', trim(strip_tags(strtolower($email))));
if (strstr($email, '%'))
{
if (strstr($email, '%')) {
$op = 'LIKE';
}
else
{
} else {
$op = '=';
}
if ($email == '') bb_die($lang['SEARCH_INVALID_EMAIL']);
if ($email == '') {
bb_die($lang['SEARCH_INVALID_EMAIL']);
}
$total_sql .= "SELECT COUNT(user_id) AS total FROM " . BB_USERS . " WHERE {$lower_b}user_email{$lower_e} $op '" . DB()->escape($email) . "' AND user_id <> " . GUEST_UID;
$select_sql .= " WHERE {$lower_b}u.user_email{$lower_e} $op '" . DB()->escape($email) . "' AND u.user_id <> " . GUEST_UID;
@ -312,16 +317,12 @@ else
$users = array();
// Let's see if they entered a full valid IPv4 address
if (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}$/', $ip_address))
{
if (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}$/', $ip_address)) {
$ip = encode_ip($ip_address);
$users[] = $ip;
}
elseif (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){0,2}\.\*/', $ip_address))
{
} elseif (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){0,2}\.\*/', $ip_address)) {
$ip_split = explode('.', $ip_address);
switch (count($ip_split))
{
switch (count($ip_split)) {
case 4:
$users[] = encode_ip($ip_split[0] . "." . $ip_split[1] . "." . $ip_split[2] . ".255");
break;
@ -332,47 +333,35 @@ else
$users[] = encode_ip($ip_split[0] . ".255.255.255");
break;
}
}
elseif (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}(\s)*-(\s)*([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}$/', $ip_address))
{
} elseif (preg_match('/^([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}(\s)*-(\s)*([0-9]{1,2}|[0-2][0-9]{0,2})(\.([0-9]{1,2}|[0-2][0-9]{0,2})){3}$/', $ip_address)) {
$range = preg_split('/[-\s]+/', $ip_address);
$start_range = explode('.', $range[0]);
$end_range = explode('.', $range[1]);
if (($start_range[0].$start_range[1].$start_range[2] != $end_range[0].$end_range[1].$end_range[2]) || ($start_range[3] > $end_range[3])) bb_die($lang['SEARCH_INVALID_IP']);
for ($i = $start_range[3]; $i <= $end_range[3]; $i++)
{
if (($start_range[0] . $start_range[1] . $start_range[2] != $end_range[0] . $end_range[1] . $end_range[2]) || ($start_range[3] > $end_range[3])) {
bb_die($lang['SEARCH_INVALID_IP']);
}
for ($i = $start_range[3]; $i <= $end_range[3]; $i++) {
$users[] = encode_ip($start_range[0] . "." . $start_range[1] . "." . $start_range[2] . "." . $i);
}
}
else
{
} else {
bb_die($lang['SEARCH_INVALID_IP']);
}
$ip_in_sql = $ip_like_sql = $ip_like_sql_flylast = $ip_like_sql_flyreg = '';
foreach ($users as $address)
{
if (preg_match('/(ff){1,3}$/i', $address))
{
if (preg_match('/[0-9a-f]{2}ffffff/i', $address))
{
foreach ($users as $address) {
if (preg_match('/(ff){1,3}$/i', $address)) {
if (preg_match('/[0-9a-f]{2}ffffff/i', $address)) {
$ip_start = substr($address, 0, 2);
}
elseif (preg_match('/[0-9a-f]{4}ffff/i', $address))
{
} elseif (preg_match('/[0-9a-f]{4}ffff/i', $address)) {
$ip_start = substr($address, 0, 4);
}
elseif (preg_match('/[0-9a-f]{6}ff/i', $address))
{
} elseif (preg_match('/[0-9a-f]{6}ff/i', $address)) {
$ip_start = substr($address, 0, 6);
}
$ip_like_sql_flylast = $ip_like_sql . ($ip_like_sql != '') ? " OR user_last_ip LIKE '" . $ip_start . "%'" : "user_last_ip LIKE '" . $ip_start . "%'";
$ip_like_sql_flyreg = $ip_like_sql . ($ip_like_sql != '') ? " OR user_reg_ip LIKE '" . $ip_start . "%'" : "user_reg_ip LIKE '" . $ip_start . "%'";
$ip_like_sql .= ($ip_like_sql != '') ? " OR poster_ip LIKE '" . $ip_start . "%'" : "poster_ip LIKE '" . $ip_start . "%'";
}
else
{
} else {
$ip_in_sql .= ($ip_in_sql == '') ? "'$address'" : ", '$address'";
}
}
@ -381,29 +370,26 @@ else
$where_sql .= ($ip_in_sql != '') ? "poster_ip IN ($ip_in_sql)" : "";
$where_sql .= ($ip_like_sql != '') ? ($where_sql != "") ? " OR $ip_like_sql" : "$ip_like_sql" : "";
if (!$where_sql) bb_die('invalid request');
if (!$where_sql) {
bb_die('invalid request');
}
// start search
$no_result_search = false;
$ip_users_sql = '';
$sql = "SELECT poster_id FROM " . BB_POSTS . " WHERE poster_id <> " . GUEST_UID . " AND ($where_sql) GROUP BY poster_id";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not count users #1');
}
if (DB()->num_rows($result) == 0)
{
if (DB()->num_rows($result) == 0) {
$no_result_search = true;
}
else
{
} else {
$total_pages['total'] = DB()->num_rows($result);
$total_sql = NULL;
$total_sql = null;
$ip_users_sql = '';
while($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$ip_users_sql .= ($ip_users_sql == '') ? $row['poster_id'] : ', ' . $row['poster_id'];
}
}
@ -411,17 +397,16 @@ else
$where_sql .= ($ip_in_sql != '') ? "user_last_ip IN ($ip_in_sql)" : "";
$where_sql .= ($ip_like_sql_flylast != '') ? ($where_sql != "") ? " OR $ip_like_sql_flylast" : "$ip_like_sql_flylast" : "";
$sql = "SELECT user_id FROM " . BB_USERS . " WHERE user_id <> " . GUEST_UID . " AND ($where_sql) GROUP BY user_id";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not count users #2');
}
if (DB()->num_rows($result) != 0)
{
if ($no_result_search == true) $no_result_search = false;
if (DB()->num_rows($result) != 0) {
if ($no_result_search == true) {
$no_result_search = false;
}
$total_pages['total'] = DB()->num_rows($result);
$total_sql = NULL;
while ($row = DB()->sql_fetchrow($result))
{
$total_sql = null;
while ($row = DB()->sql_fetchrow($result)) {
$ip_users_sql .= ($ip_users_sql == '') ? $row['user_id'] : ', ' . $row['user_id'];
}
}
@ -429,22 +414,20 @@ else
$where_sql .= ($ip_in_sql != '') ? "user_reg_ip IN ($ip_in_sql)" : "";
$where_sql .= ($ip_like_sql_flyreg != '') ? ($where_sql != "") ? " OR $ip_like_sql_flyreg" : "$ip_like_sql_flyreg" : "";
$sql = "SELECT user_id FROM " . BB_USERS . " WHERE user_id <> " . GUEST_UID . " AND ($where_sql) GROUP BY user_id";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not count users #3');
}
if (DB()->num_rows($result) != 0)
{
if ($no_result_search == true) $no_result_search = false;
if (DB()->num_rows($result) != 0) {
if ($no_result_search == true) {
$no_result_search = false;
}
$total_pages['total'] = DB()->num_rows($result);
$total_sql = NULL;
while ($row = DB()->sql_fetchrow($result))
{
$total_sql = null;
while ($row = DB()->sql_fetchrow($result)) {
$ip_users_sql .= ($ip_users_sql == '') ? $row['user_id'] : ', ' . $row['user_id'];
}
}
if ($no_result_search == true)
{
if ($no_result_search == true) {
bb_die($lang['SEARCH_NO_RESULTS']);
}
@ -456,29 +439,25 @@ else
$date_type = trim(strtolower($date_type));
if ($date_type != 'before' && $date_type != 'after')
{
if ($date_type != 'before' && $date_type != 'after') {
bb_die($lang['SEARCH_INVALID_DATE']);
}
$date_day = intval($date_day);
if (!preg_match('/^([1-9]|[0-2][0-9]|3[0-1])$/', $date_day))
{
if (!preg_match('/^([1-9]|[0-2][0-9]|3[0-1])$/', $date_day)) {
bb_die($lang['SEARCH_INVALID_DAY']);
}
$date_month = intval($date_month);
if (!preg_match('/^(0?[1-9]|1[0-2])$/', $date_month))
{
if (!preg_match('/^(0?[1-9]|1[0-2])$/', $date_month)) {
bb_die($lang['SEARCH_INVALID_MONTH']);
}
$date_year = intval($date_year);
if (!preg_match('/^(20[0-9]{2}|19[0-9]{2})$/', $date_year))
{
if (!preg_match('/^(20[0-9]{2}|19[0-9]{2})$/', $date_year)) {
bb_die($lang['SEARCH_INVALID_YEAR']);
}
@ -486,12 +465,9 @@ else
$time = mktime(0, 0, 0, $date_month, $date_day, $date_year);
if ($date_type == 'before')
{
if ($date_type == 'before') {
$arg = '<';
}
else
{
} else {
$arg = '>';
}
@ -504,20 +480,17 @@ else
$base_url .= '&search_group=true&group_id=' . rawurlencode($group_id);
if (!$group_id)
{
if (!$group_id) {
bb_die($lang['SEARCH_INVALID_GROUP']);
}
$sql = "SELECT group_name FROM " . BB_GROUPS . " WHERE group_id = $group_id AND group_single_user = 0";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not select group data #2');
}
if (DB()->num_rows($result)==0)
{
if (DB()->num_rows($result) == 0) {
bb_die($lang['SEARCH_INVALID_GROUP']);
}
@ -542,20 +515,17 @@ else
$base_url .= '&search_rank=true&rank_id=' . rawurlencode($rank_id);
if (!$rank_id)
{
if (!$rank_id) {
bb_die($lang['SEARCH_INVALID_RANK']);
}
$sql = "SELECT rank_title FROM " . BB_RANKS . " WHERE rank_id = $rank_id AND rank_special = 1";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not select rank data');
}
if (DB()->num_rows($result)==0)
{
if (DB()->num_rows($result) == 0) {
bb_die($lang['SEARCH_INVALID_RANK']);
}
@ -578,8 +548,7 @@ else
$base_url .= '&search_postcount=true&postcount_type=' . rawurlencode($postcount_type) . '&postcount_value=' . rawurlencode(stripslashes($postcount_value));
switch($postcount_type)
{
switch ($postcount_type) {
case 'greater':
$postcount_value = intval($postcount_value);
@ -608,15 +577,13 @@ else
break;
case 'equals':
// looking for a -
if (strstr($postcount_value, '-'))
{
if (strstr($postcount_value, '-')) {
$range = preg_split('/[-\s]+/', $postcount_value);
$range_begin = intval($range[0]);
$range_end = intval($range[1]);
if ($range_begin > $range_end)
{
if ($range_begin > $range_end) {
bb_die($lang['SEARCH_INVALID_POSTCOUNT']);
}
@ -631,9 +598,7 @@ else
$select_sql .= " WHERE u.user_posts >= $range_begin
AND u.user_posts <= $range_end
AND u.user_id <> " . GUEST_UID;
}
else
{
} else {
$postcount_value = intval($postcount_value);
$text = sprintf($lang['SEARCH_FOR_POSTCOUNT_EQUALS'], $postcount_value);
@ -659,21 +624,19 @@ else
$userfield_value = preg_replace('/\*/', '%', trim(strip_tags(strtolower($userfield_value))));
if (strstr($userfield_value, '%'))
{
if (strstr($userfield_value, '%')) {
$op = 'LIKE';
}
else
{
} else {
$op = '=';
}
if ($userfield_value == '') bb_die($lang['SEARCH_INVALID_USERFIELD']);
if ($userfield_value == '') {
bb_die($lang['SEARCH_INVALID_USERFIELD']);
}
$userfield_type = trim(strtolower($userfield_type));
switch ($userfield_type)
{
switch ($userfield_type) {
case 'icq':
$text = sprintf($lang['SEARCH_FOR_USERFIELD_ICQ'], $text);
$field = 'user_icq';
@ -723,8 +686,7 @@ else
$lastvisited_seconds = (TIMENOW - ((($lastvisited_days * 24) * 60) * 60));
switch($lastvisited_type)
{
switch ($lastvisited_type) {
case 'in':
$text = sprintf($lang['SEARCH_FOR_LASTVISITED_INTHELAST'], $lastvisited_days, (($lastvisited_days > 1) ? $lang['DAYS'] : $lang['DAY']));
@ -758,8 +720,7 @@ else
$language_type = trim(strtolower(stripslashes($language_type)));
if ($language_type == '')
{
if ($language_type == '') {
bb_die($lang['SEARCH_INVALID_LANGUAGE']);
}
@ -795,13 +756,11 @@ else
$sql = "SELECT forum_name FROM " . BB_FORUMS . " WHERE forum_id = " . $moderators_forum;
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not select forum data');
}
if (DB()->num_rows($result)==0)
{
if (DB()->num_rows($result) == 0) {
bb_die($lang['SEARCH_INVALID_MODERATORS']);
}
@ -834,8 +793,7 @@ else
$base_url .= '&search_misc=true&misc=' . rawurlencode(stripslashes($misc));
switch ($misc)
{
switch ($misc) {
case 'admins':
$text = $lang['SEARCH_FOR_ADMINS'];
@ -890,8 +848,7 @@ else
$select_sql .= " ORDER BY ";
switch (strtolower(@$_GET['sort']))
{
switch (strtolower(@$_GET['sort'])) {
case 'regdate':
$sort = 'regdate';
$select_sql .= 'u.user_regdate';
@ -918,8 +875,7 @@ else
$select_sql .= 'u.username';
}
switch (@$_GET['order'])
{
switch (@$_GET['order']) {
case 'DESC':
$order = 'DESC';
$o_order = 'ASC';
@ -934,17 +890,13 @@ else
$page = (isset($_GET['page'])) ? intval($_GET['page']) : intval(trim(@$_POST['page']));
if ($page < 1)
{
if ($page < 1) {
$page = 1;
}
if ($page == 1)
{
if ($page == 1) {
$offset = 0;
}
else
{
} else {
$offset = (($page - 1) * $bb_cfg['topics_per_page']);
}
@ -952,17 +904,14 @@ else
$select_sql .= " $limit";
if (!is_null($total_sql))
{
if (!$result = DB()->sql_query($total_sql))
{
if (!is_null($total_sql)) {
if (!$result = DB()->sql_query($total_sql)) {
bb_die('Could not count users');
}
$total_pages = DB()->sql_fetchrow($result);
if ($total_pages['total'] == 0)
{
if ($total_pages['total'] == 0) {
bb_die($lang['SEARCH_NO_RESULTS']);
}
}
@ -970,16 +919,13 @@ else
$pagination = '';
if ($page > 1)
{
if ($page > 1) {
$pagination .= '<a href="' . $base_url . '&sort=' . $sort . '&order=' . $order . '&page=' . ($page - 1) . '">' . $lang['PREVIOUS'] . '</a>';
}
if ($page < $num_pages)
{
if ($page < $num_pages) {
$pagination .= ($pagination == '') ? '<a href="' . $base_url . '&sort=' . $sort . '&order=' . $order . '&page=' . ($page + 1) . '">' . $lang['NEXT'] . '</a>' : ' | <a href="' . $base_url . '&sort=' . $sort . '&order=' . $order . '&page=' . ($page + 1) . '">' . $lang['NEXT'] . '</a>';
}
if ($num_pages > 2)
{
if ($num_pages > 2) {
$pagination .= '&nbsp;&nbsp;<input type="text" name="page" maxlength="5" size="2" class="post" />&nbsp;<input type="submit" name="submit" value="' . $lang['GO'] . '" class="post" />';
}
$template->assign_vars(array(
@ -998,8 +944,7 @@ else
'S_POST_ACTION' => "$base_url&sort=$sort&order=$order"
));
if (!$result = DB()->sql_query($select_sql))
{
if (!$result = DB()->sql_query($select_sql)) {
bb_die('Could not select user data');
}
@ -1007,15 +952,13 @@ else
$users_sql = '';
foreach ($rowset as $array)
{
foreach ($rowset as $array) {
$users_sql .= ($users_sql == '') ? $array['user_id'] : ', ' . $array['user_id'];
}
$sql = "SELECT ban_userid AS user_id FROM " . BB_BANLIST . " WHERE ban_userid IN ($users_sql)";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not select banned data');
}
@ -1023,13 +966,11 @@ else
$banned = array();
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$banned[$row['user_id']] = true;
}
for ($i = 0; $i < count($rowset); $i++)
{
for ($i = 0; $i < count($rowset); $i++) {
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('userrow', array(

View file

@ -1,44 +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 (!empty($setmodules))
{
if (!empty($setmodules)) {
$module['GENERAL']['WORD_CENSOR'] = basename(__FILE__);
return;
}
require('./pagestart.php');
if (!$bb_cfg['use_word_censor'])
{
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']))
{
if (isset($_POST['add'])) {
$mode = 'add';
}
else if (isset($_POST['save']))
{
} elseif (isset($_POST['save'])) {
$mode = 'save';
}
if ($mode != '')
{
if ($mode == 'edit' || $mode == 'add')
{
if ($mode != '') {
if ($mode == 'edit' || $mode == 'add') {
$word_id = intval(request_var('id', 0));
$s_hidden_fields = $word = $replacement = '';
if ($mode == 'edit')
{
if ($word_id)
{
if ($mode == 'edit') {
if ($word_id) {
$sql = "SELECT * FROM " . BB_WORDS . " WHERE word_id = $word_id";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query words table #1');
}
@ -46,9 +59,7 @@ if ($mode != '')
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
$word = $word_info['word'];
$replacement = $word_info['replacement'];
}
else
{
} else {
bb_die($lang['NO_WORD_SELECTED']);
}
}
@ -60,34 +71,27 @@ if ($mode != '')
'S_WORDS_ACTION' => 'admin_words.php',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else if ($mode == 'save')
{
} elseif ($mode == 'save') {
$word_id = intval(request_var('id', 0));
$word = trim(request_var('word', ''));
$replacement = trim(request_var('replacement', ''));
if ($word == '' || $replacement == '')
{
if ($word == '' || $replacement == '') {
bb_die($lang['MUST_ENTER_WORD']);
}
if ($word_id)
{
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
{
} else {
$sql = "INSERT INTO " . BB_WORDS . " (word, replacement)
VALUES ('" . DB()->escape($word) . "', '" . DB()->escape($replacement) . "')";
$message = $lang['WORD_ADDED'];
}
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not insert data into words table');
}
@ -95,35 +99,26 @@ if ($mode != '')
$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')
{
} elseif ($mode == 'delete') {
$word_id = intval(request_var('id', 0));
if ($word_id)
{
if ($word_id) {
$sql = "DELETE FROM " . BB_WORDS . " WHERE word_id = $word_id";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not remove data from words table');
}
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
{
} else {
bb_die($lang['NO_WORD_SELECTED']);
}
}
}
else
{
} else {
$sql = "SELECT * FROM " . BB_WORDS . " ORDER BY word";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query words table #2');
}
@ -136,8 +131,7 @@ else
'S_HIDDEN_FIELDS' => '',
));
for ($i = 0; $i < $word_count; $i++)
{
for ($i = 0; $i < $word_count; $i++) {
$word = $word_rows[$i]['word'];
$replacement = $word_rows[$i]['replacement'];
$word_id = $word_rows[$i]['word_id'];

View file

@ -1,18 +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.
*/
require('./pagestart.php');
// Generate relevant output
if (isset($_GET['pane']) && $_GET['pane'] == 'left')
{
if (!$module = CACHE('bb_cache')->get('admin_module'))
{
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))
{
while ($file = @readdir($dir)) {
if (preg_match('/^admin_.*?\.php$/', $file)) {
include('./' . $file);
}
}
@ -29,8 +48,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left')
ksort($module);
while (list($cat, $action_array) = each($module))
{
while (list($cat, $action_array) = each($module)) {
$cat = (!empty($lang[$cat])) ? $lang[$cat] : preg_replace('/_/', ' ', $cat);
$template->assign_block_vars('catrow', array(
@ -40,8 +58,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left')
ksort($action_array);
$row_count = 0;
while (list($action, $file) = each($action_array))
{
while (list($action, $file) = each($action_array)) {
$row_class = !($row_count % 2) ? 'row1' : 'row2';
$action = (!empty($lang[$action])) ? $lang[$action] : preg_replace('/_/', ' ', $action);
@ -54,9 +71,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left')
$row_count++;
}
}
}
elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
{
} elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') {
$template->assign_vars(array(
'TPL_ADMIN_MAIN' => true,
'ADMIN_LOCK' => ($bb_cfg['board_disable']) ? true : false,
@ -76,61 +91,47 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
$avatar_dir_size = 0;
if ($avatar_dir = @opendir(BB_ROOT . $bb_cfg['avatar_path']))
{
while( $file = @readdir($avatar_dir) )
{
if( $file != '.' && $file != '..' )
{
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
{
} else {
$avatar_dir_size = $lang['NOT_AVAILABLE'];
}
if (intval($posts_per_day) > $total_posts)
{
if (intval($posts_per_day) > $total_posts) {
$posts_per_day = $total_posts;
}
if (intval($topics_per_day) > $total_topics)
{
if (intval($topics_per_day) > $total_topics) {
$topics_per_day = $total_topics;
}
if ($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))
{
if ($result = DB()->sql_query($sql)) {
$row = DB()->sql_fetchrow($result);
$version = $row['mysql_version'];
if (preg_match('/^(3\.23|4\.|5\.|10\.)/', $version))
{
if (preg_match('/^(3\.23|4\.|5\.|10\.)/', $version)) {
$dblist = array();
foreach ($bb_cfg['db'] as $name => $row)
{
foreach ($bb_cfg['db'] as $name => $row) {
$sql = "SHOW TABLE STATUS FROM {$row[1]}";
if ($result = DB()->sql_query($sql))
{
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' )
{
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'];
}
}
@ -138,14 +139,10 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
}
}
$dbsize = implode('&nbsp;|&nbsp;', $dblist);
}
else
{
} else {
$dbsize = $lang['NOT_AVAILABLE'];
}
}
else
{
} else {
$dbsize = $lang['NOT_AVAILABLE'];
}
@ -162,8 +159,7 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
'GZIP_COMPRESSION' => ($bb_cfg['gzip_compress']) ? $lang['ON'] : $lang['OFF'],
));
if (@$_GET['users_online'])
{
if (@$_GET['users_online']) {
$template->assign_vars(array(
'SHOW_USERS_ONLINE' => true,
));
@ -176,8 +172,7 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
AND u.user_id <> " . GUEST_UID . "
AND s.session_time >= " . (TIMENOW - 300) . "
ORDER BY s.session_ip ASC, s.session_time DESC";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain reged user / online information');
}
$onlinerow_reg = DB()->sql_fetchrowset($result);
@ -187,35 +182,28 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
WHERE session_logged_in = 0
AND session_time >= " . (TIMENOW - 300) . "
ORDER BY session_ip ASC, session_time DESC";
if (!$result = DB()->sql_query($sql))
{
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();
if (count($onlinerow_reg))
{
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))
{
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'];
if (bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline'))
{
if (bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline')) {
$hidden_users++;
$hidden = TRUE;
}
else
{
$hidden = true;
} else {
$registered_users++;
$hidden = FALSE;
$hidden = false;
}
$row_class = 'row1';
@ -235,12 +223,10 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
}
// Guest users
if (count($onlinerow_guest))
{
if (count($onlinerow_guest)) {
$guest_users = 0;
for ($i = 0; $i < count($onlinerow_guest); $i++)
{
for ($i = 0; $i < count($onlinerow_guest); $i++) {
$guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
$guest_users++;
@ -257,16 +243,12 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right')
));
}
}
}
else
{
} else {
$template->assign_vars(array(
'USERS_ONLINE_HREF' => 'index.php?pane=right&users_online=1',
));
}
}
else
{
} else {
// Generate frameset
$template->assign_vars(array(
'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'],
@ -281,10 +263,8 @@ print_page('index.tpl', 'admin');
// Functions
function inarray($needle, $haystack)
{
for ($i = 0; $i < sizeof($haystack); $i++)
{
if ($haystack[$i] == $needle)
{
for ($i = 0; $i < sizeof($haystack); $i++) {
if ($haystack[$i] == $needle) {
return true;
}
}

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_ROOT', './../');
define('IN_FORUM', true);
@ -11,18 +34,15 @@ require_once(INC_DIR .'functions_admin.php');
$user->session_start();
if (IS_GUEST)
{
if (IS_GUEST) {
redirect(LOGIN_URL . "?redirect=admin/index.php");
}
if (!IS_ADMIN)
{
if (!IS_ADMIN) {
bb_die($lang['NOT_ADMIN']);
}
if (!$userdata['session_admin'])
{
if (!$userdata['session_admin']) {
$redirect = url_arg($_SERVER['REQUEST_URI'], 'admin', 1);
redirect("login.php?redirect=$redirect");
}

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_ADMIN', true);
define('BB_ROOT', './../../');
@ -6,7 +29,9 @@ 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';
@ -22,8 +47,7 @@ echo '
<br /><br />
<table border="1" cellspacing="0" cellpadding="6" align="center">';
foreach ($sql as $i => $query)
{
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>";
}
@ -32,11 +56,9 @@ echo '</table>';
echo '<div align="center"><pre>';
if ($l = sys('la'))
{
if ($l = sys('la')) {
$l = explode(' ', $l);
for ($i=0; $i < 3; $i++)
{
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";

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_ADMIN', true);
define('BB_ROOT', './../../');
@ -6,7 +29,9 @@ 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;
@ -52,8 +77,7 @@ $stat += DB()->fetch_row("SELECT COUNT(*) AS tor_all, SUM(size) AS torrents_size
// Last xx minutes
$peers_in_last_min = array();
foreach ($peers_in_last_minutes as $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) . "
");
@ -62,8 +86,7 @@ foreach ($peers_in_last_minutes as $t)
// 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)
{
foreach ($rowset as $cnt => $row) {
$peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt % 15)) ? " \n" : '');
}
@ -71,10 +94,12 @@ function commify_callback ($matches)
{
return commify($matches[0]);
}
function commify_ob($contents)
{
return preg_replace_callback("#\b\d+\b#", 'commify_callback', $contents);
}
ob_start('commify_ob');
echo '<html><body><head></head>';
@ -116,11 +141,9 @@ echo '</table>';
echo '<div align="center"><pre>';
if ($l = sys('la'))
{
if ($l = sys('la')) {
$l = explode(' ', $l);
for ($i=0; $i < 3; $i++)
{
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";

164
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,21 +36,16 @@ $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'])
{
if ($ajax->action != 'manage_admin') {
if ($bb_cfg['board_disable']) {
$ajax->ajax_die($lang['BOARD_DISABLE']);
}
else if (file_exists(BB_DISABLED))
{
} elseif (file_exists(BB_DISABLED)) {
$ajax->ajax_die($lang['BOARD_DISABLE_CRON']);
}
}
// Load actions required modules
switch ($ajax->action)
{
switch ($ajax->action) {
case 'view_post':
require(INC_DIR . 'bbcode.php');
break;
@ -81,10 +99,10 @@ $ajax->exec();
//
class ajax_common
{
var $request = array();
var $response = array();
public $request = array();
public $response = array();
var $valid_actions = array(
public $valid_actions = array(
// ACTION NAME AJAX_AUTH
'edit_user_profile' => array('admin'),
'change_user_rank' => array('admin'),
@ -111,12 +129,12 @@ class ajax_common
'index_data' => array('guest'),
);
var $action = null;
public $action = null;
/**
* Constructor
*/
function ajax_common()
public function ajax_common()
{
ob_start(array(&$this, 'ob_handler'));
header('Content-Type: text/plain');
@ -125,47 +143,40 @@ class ajax_common
/**
* Perform action
*/
function exec()
public function exec()
{
global $lang;
// Exit if we already have errors
if (!empty($this->response['error_code']))
{
if (!empty($this->response['error_code'])) {
$this->send();
}
// Check that requested action is valid
$action = $this->action;
if (!$action || !is_string($action))
{
if (!$action || !is_string($action)) {
$this->ajax_die('no action specified');
}
elseif (!$action_params =& $this->valid_actions[$action])
{
} elseif (!$action_params =& $this->valid_actions[$action]) {
$this->ajax_die('invalid action: ' . $action);
}
// Auth check
switch ($action_params[AJAX_AUTH])
{
switch ($action_params[AJAX_AUTH]) {
// GUEST
case 'guest':
break;
// USER
case 'user':
if (IS_GUEST)
{
if (IS_GUEST) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
}
break;
// MOD
case 'mod':
if (!IS_AM)
{
if (!IS_AM) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
$this->check_admin_session();
@ -173,8 +184,7 @@ class ajax_common
// ADMIN
case 'admin':
if (!IS_ADMIN)
{
if (!IS_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_ADMIN']);
}
$this->check_admin_session();
@ -182,8 +192,7 @@ class ajax_common
// SUPER_ADMIN
case 'super_admin':
if (!IS_SUPER_ADMIN)
{
if (!IS_SUPER_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
}
$this->check_admin_session();
@ -203,7 +212,7 @@ class ajax_common
/**
* Exit on error
*/
function ajax_die($error_msg, $error_code = E_AJAX_GENERAL_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;
@ -214,7 +223,7 @@ class ajax_common
/**
* Initialization
*/
function init()
public function init()
{
$this->request = $_POST;
$this->action =& $this->request['action'];
@ -223,12 +232,11 @@ class ajax_common
/**
* Send data
*/
function send()
public function send()
{
$this->response['action'] = $this->action;
if (DBG_USER && SQL_DEBUG && !empty($_COOKIE['sql_log']))
{
if (DBG_USER && SQL_DEBUG && !empty($_COOKIE['sql_log'])) {
$this->response['sql_log'] = get_sql_log();
}
@ -239,22 +247,18 @@ class ajax_common
/**
* OB Handler
*/
function ob_handler($contents)
{
if (DBG_USER)
{
if ($contents)
public function ob_handler($contents)
{
if (DBG_USER) {
if ($contents) {
$this->response['raw_output'] = $contents;
}
}
$response_js = Zend\Json\Json::encode($this->response);
if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP'))
{
if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000)
{
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);
}
@ -266,24 +270,19 @@ class ajax_common
/**
* Admin session
*/
function check_admin_session()
public function check_admin_session()
{
global $user;
if (!$user->data['session_admin'])
{
if (empty($this->request['user_password']))
{
if (!$user->data['session_admin']) {
if (empty($this->request['user_password'])) {
$this->prompt_for_password();
}
else
{
} else {
$login_args = array(
'login_username' => $user->data['username'],
'login_password' => $_POST['user_password'],
);
if (!$user->login($login_args, true))
{
if (!$user->login($login_args, true)) {
$this->ajax_die('Wrong password');
}
}
@ -293,7 +292,7 @@ class ajax_common
/**
* Prompt for password
*/
function prompt_for_password()
public function prompt_for_password()
{
$this->response['prompt_password'] = 1;
$this->send();
@ -302,9 +301,11 @@ class ajax_common
/**
* Prompt for confirmation
*/
function prompt_for_confirm($confirm_msg)
public function prompt_for_confirm($confirm_msg)
{
if (empty($confirm_msg)) $this->ajax_die('false');
if (empty($confirm_msg)) {
$this->ajax_die('false');
}
$this->response['prompt_confirm'] = 1;
$this->response['confirm_msg'] = $confirm_msg;
@ -314,114 +315,113 @@ class ajax_common
/**
* Verify mod rights
*/
function verify_mod_rights($forum_id)
public function verify_mod_rights($forum_id)
{
global $userdata, $lang;
$is_auth = auth(AUTH_MOD, $forum_id, $userdata);
if (!$is_auth['auth_mod'])
{
if (!$is_auth['auth_mod']) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
}
function edit_user_profile()
public function edit_user_profile()
{
require(AJAX_DIR . 'edit_user_profile.php');
}
function change_user_rank()
public function change_user_rank()
{
require(AJAX_DIR . 'change_user_rank.php');
}
function change_user_opt()
public function change_user_opt()
{
require(AJAX_DIR . 'change_user_opt.php');
}
function gen_passkey()
public function gen_passkey()
{
require(AJAX_DIR . 'gen_passkey.php');
}
function group_membership()
public function group_membership()
{
require(AJAX_DIR . 'group_membership.php');
}
function manage_group()
public function manage_group()
{
require(AJAX_DIR . 'edit_group_profile.php');
}
function post_mod_comment()
public function post_mod_comment()
{
require(AJAX_DIR . 'post_mod_comment.php');
}
function view_post()
public function view_post()
{
require(AJAX_DIR . 'view_post.php');
}
function change_tor_status()
public function change_tor_status()
{
require(AJAX_DIR . 'change_tor_status.php');
}
function change_torrent()
public function change_torrent()
{
require(AJAX_DIR . 'change_torrent.php');
}
function view_torrent()
public function view_torrent()
{
require(AJAX_DIR . 'view_torrent.php');
}
function user_register()
public function user_register()
{
require(AJAX_DIR . 'user_register.php');
}
function mod_action()
public function mod_action()
{
require(AJAX_DIR . 'mod_action.php');
}
function posts()
public function posts()
{
require(AJAX_DIR . 'posts.php');
}
function manage_user()
public function manage_user()
{
require(AJAX_DIR . 'manage_user.php');
}
function manage_admin()
public function manage_admin()
{
require(AJAX_DIR . 'manage_admin.php');
}
function topic_tpl()
public function topic_tpl()
{
require(AJAX_DIR . 'topic_tpl.php');
}
function index_data()
public function index_data()
{
require(AJAX_DIR . 'index_data.php');
}
function avatar()
public function avatar()
{
require(AJAX_DIR . 'avatar.php');
}
function sitemap()
public function sitemap()
{
require(AJAX_DIR . 'sitemap.php');
}

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.
*/
define('IN_TRACKER', true);
define('BB_ROOT', './../');
require(BB_ROOT . 'common.php');
if (empty($_SERVER['HTTP_USER_AGENT']))
{
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');
if (isset($_GET['event']) && $_GET['event'] === 'completed') {
if (DBG_LOG) {
dbg_log(' ', '!die-event-completed');
}
dummy_exit(mt_rand(600, 1200));
}
@ -25,18 +48,15 @@ $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']))
{
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)
{
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)
{
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)');
}
@ -60,13 +80,11 @@ $input_vars_num = array(
// Init received data
// String
foreach ($input_vars_str as $var_name)
{
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)
{
foreach ($input_vars_num as $var_name) {
$$var_name = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null;
}
// Passkey
@ -74,52 +92,38 @@ $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)
{
if (!isset($info_hash) || strlen($info_hash) != 20) {
msg_die('Invalid info_hash');
}
if (!isset($peer_id) || strlen($peer_id) != 20)
{
if (!isset($peer_id) || strlen($peer_id) != 20) {
msg_die('Invalid peer_id');
}
if (!isset($port) || $port < 0 || $port > 0xFFFF)
{
if (!isset($port) || $port < 0 || $port > 0xFFFF) {
msg_die('Invalid port');
}
if (!isset($uploaded) || $uploaded < 0 || $uploaded > $max_up_down_val || $uploaded == 1844674407370)
{
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)
{
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)
{
if (!isset($left) || $left < 0 || $left > $max_left_val) {
msg_die('Invalid left value');
}
if (!verify_id($passkey, BT_AUTH_KEY_LENGTH))
{
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'])
{
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))
{
} 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;
@ -129,8 +133,7 @@ if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip'])
}
}
// Check that IP format is valid
if (!verify_ip($ip))
{
if (!verify_ip($ip)) {
msg_die("Invalid IP: $ip");
}
// Convert IP to HEX format
@ -144,11 +147,12 @@ $peer_hash = md5(
// 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'))
{
if ($lp_info && (!isset($event) || $event !== 'stopped')) {
drop_fast_announce($lp_info);
}
@ -157,8 +161,7 @@ function drop_fast_announce ($lp_info)
{
global $announce_interval;
if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60))
{
if ($lp_info['update_time'] < (TIMENOW - $announce_interval + 60)) {
return; // if announce interval correct
}
@ -169,7 +172,9 @@ function drop_fast_announce ($lp_info)
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(
# 'interval' => (int) 1800,
@ -193,26 +198,26 @@ $seeder = ($left == 0) ? 1 : 0;
$stopped = ($event === 'stopped');
// Stopped event
if ($stopped)
{
if ($stopped) {
CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash);
if (DBG_LOG) dbg_log(' ', 'stopped');
if (DBG_LOG) {
dbg_log(' ', 'stopped');
}
}
// Get last peer info from DB
if (!CACHE('tr_cache')->used && !$lp_info)
{
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)
{
if ($lp_info) {
if (!$stopped) {
drop_fast_announce($lp_info);
}
@ -220,9 +225,7 @@ if ($lp_info)
$topic_id = $lp_info['topic_id'];
$releaser = $lp_info['releaser'];
$tor_type = $lp_info['tor_type'];
}
else
{
} else {
// Verify if torrent registered on tracker and user authorized
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$passkey_sql = DB()->escape($passkey);
@ -237,12 +240,10 @@ else
$row = DB()->fetch_row($sql);
if (empty($row['topic_id']))
{
if (empty($row['topic_id'])) {
msg_die('Torrent not registered, info_hash = ' . bin2hex($info_hash_sql));
}
if (empty($row['user_id']))
{
if (empty($row['user_id'])) {
msg_die('Please LOG IN and REDOWNLOAD this torrent (user not found)');
}
@ -252,17 +253,13 @@ else
$tor_type = $row['tor_type'];
// Ratio limits
if ((TR_RATING_LIMITS || $tr_cfg['limit_concurrent_ips']) && !$stopped)
{
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)
{
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)";
@ -272,36 +269,29 @@ else
}
// 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)))
{
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)
{
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'])
{
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'])
{
} 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)))
{
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
@ -309,20 +299,15 @@ else
AND seeder = $seeder
AND ip != '$ip_sql'";
if (!$seeder && $tr_cfg['leech_expire_factor'])
{
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'])
{
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'])
{
} 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");
}
}
@ -333,14 +318,11 @@ else
// Up/Down speed
$speed_up = $speed_down = 0;
if ($lp_info && $lp_info['update_time'] < TIMENOW)
{
if ($uploaded > $lp_info['uploaded'])
{
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'])
{
if ($downloaded > $lp_info['downloaded']) {
$speed_down = ceil(($downloaded - $lp_info['downloaded']) / (TIMENOW - $lp_info['update_time']));
}
}
@ -350,15 +332,11 @@ $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)
{
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)
{
} // Silver releases
elseif ($tor_type == TOR_TYPE_SILVER) {
$down_add = ceil($down_add / 2);
}
}
@ -367,8 +345,7 @@ if ($tr_cfg['gold_silver_enabled'] && $down_add)
$peer_info_updated = false;
$update_time = ($stopped) ? 0 : TIMENOW;
if ($lp_info)
{
if ($lp_info) {
$sql = "UPDATE " . BB_BT_TRACKER . " SET update_time = $update_time";
$sql .= ", seeder = $seeder";
@ -393,22 +370,24 @@ if ($lp_info)
$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)
{
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)");
if (DBG_LOG) dbg_log(' ', 'this_peer-insert');
if (DBG_LOG) {
dbg_log(' ', 'this_peer-insert');
}
}
// Exit if stopped
if ($stopped)
{
if ($stopped) {
silent_exit();
}
@ -426,15 +405,18 @@ $lp_info = array(
$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)
{
if (!$output) {
// Retrieve peers
$numwant = (int)$tr_cfg['numwant'];
$compact_mode = ($tr_cfg['compact_mode'] || !empty($compact));
@ -447,21 +429,16 @@ if (!$output)
LIMIT $numwant
");
if ($compact_mode)
{
if ($compact_mode) {
$peers = '';
foreach ($rowset as $peer)
{
foreach ($rowset as $peer) {
$peers .= pack('Nn', ip2long(decode_ip($peer['ip'])), $peer['port']);
}
}
else
{
} else {
$peers = array();
foreach ($rowset as $peer)
{
foreach ($rowset as $peer) {
$peers[] = array(
'ip' => decode_ip($peer['ip']),
'port' => intval($peer['port']),
@ -472,8 +449,7 @@ if (!$output)
$seeders = 0;
$leechers = 0;
if ($tr_cfg['scrape'])
{
if ($tr_cfg['scrape']) {
$row = DB()->fetch_row("
SELECT seeders, leechers
FROM " . BB_BT_TRACKER_SNAP . "
@ -495,7 +471,9 @@ if (!$output)
$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

View file

@ -1,9 +1,36 @@
<?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
@ -12,10 +39,8 @@ function tracker_exit ()
{
global $DBS;
if (DBG_LOG && DBG_TRACKER)
{
if ($gen_time = utime() - TIMESTART)
{
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);
@ -42,7 +67,9 @@ function silent_exit ()
function error_exit($msg = '')
{
if (DBG_LOG) dbg_log(' ', '!err-'. clean_filename($msg));
if (DBG_LOG) {
dbg_log(' ', '!err-' . clean_filename($msg));
}
silent_exit();
@ -80,7 +107,7 @@ class sql_db
/**
* Constructor
*/
function __construct ($cfg_values)
public function __construct($cfg_values)
{
global $DBS;
@ -96,7 +123,7 @@ class sql_db
/**
* Initialize connection
*/
function init ()
public function init()
{
// Connect to server
$this->link = $this->connect();
@ -105,10 +132,8 @@ class sql_db
$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']}"))
{
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']}");
}
}
@ -121,15 +146,14 @@ class sql_db
/**
* Open connection
*/
function connect ()
public function connect()
{
$this->cur_query = 'connect';
$this->debug('start');
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
if (!$link = $connect_type($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd']))
{
if (!$link = $connect_type($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd'])) {
$this->log_error();
}
@ -140,14 +164,10 @@ class sql_db
# if (DBG_LOG) dbg_log(' ', 'DB-connect'. ($link ? '' : '-FAIL'));
if (!$link)
{
if (function_exists('dummy_exit'))
{
if (!$link) {
if (function_exists('dummy_exit')) {
dummy_exit(mt_rand(1200, 2400));
}
else
{
} else {
die;
}
}
@ -158,13 +178,12 @@ class sql_db
/**
* Select database
*/
function select_db ()
public function select_db()
{
$this->cur_query = 'select db';
$this->debug('start');
if (!mysql_select_db($this->cfg['dbname'], $this->link))
{
if (!mysql_select_db($this->cfg['dbname'], $this->link)) {
$this->log_error();
error_exit("Could not select database '{$this->cfg['dbname']}'");
}
@ -178,17 +197,15 @@ class sql_db
/**
* Base query method
*/
function sql_query ($query)
{
if (!is_resource($this->link))
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))
{
if (!$this->result = mysql_query($query, $this->link)) {
$this->log_error();
}
@ -204,10 +221,9 @@ class sql_db
/**
* Execute query WRAPPER (with error handling)
*/
function query ($query)
{
if (!$result = $this->sql_query($query))
public function query($query)
{
if (!$result = $this->sql_query($query)) {
$this->trigger_error();
}
@ -217,12 +233,11 @@ class sql_db
/**
* Return number of rows
*/
function num_rows ($result = false)
public function num_rows($result = false)
{
$num_rows = false;
if ($result OR $result = $this->result)
{
if ($result or $result = $this->result) {
$num_rows = is_resource($result) ? mysql_num_rows($result) : false;
}
@ -232,7 +247,7 @@ class sql_db
/**
* Return number of affected rows
*/
function affected_rows ()
public function affected_rows()
{
return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
}
@ -240,7 +255,7 @@ class sql_db
/**
* Fetch current row
*/
function sql_fetchrow ($result)
public function sql_fetchrow($result)
{
return is_resource($result) ? mysql_fetch_assoc($result) : false;
}
@ -248,7 +263,7 @@ class sql_db
/**
* Alias of sql_fetchrow()
*/
function fetch_next ($result)
public function fetch_next($result)
{
return $this->sql_fetchrow($result);
}
@ -256,10 +271,9 @@ class sql_db
/**
* Fetch row WRAPPER (with error handling)
*/
function fetch_row ($query)
{
if (!$result = $this->sql_query($query))
public function fetch_row($query)
{
if (!$result = $this->sql_query($query)) {
$this->trigger_error();
}
@ -269,12 +283,11 @@ class sql_db
/**
* Fetch all rows
*/
function sql_fetchrowset ($result)
public function sql_fetchrowset($result)
{
$rowset = array();
while ($row = mysql_fetch_assoc($result))
{
while ($row = mysql_fetch_assoc($result)) {
$rowset[] = $row;
}
@ -284,10 +297,9 @@ class sql_db
/**
* Fetch all rows WRAPPER (with error handling)
*/
function fetch_rowset ($query)
{
if (!$result = $this->sql_query($query))
public function fetch_rowset($query)
{
if (!$result = $this->sql_query($query)) {
$this->trigger_error();
}
@ -297,24 +309,26 @@ class sql_db
/**
* Escape string used in sql query
*/
function escape ($v, $check_type = false)
{
if (!is_resource($this->link))
public function escape($v, $check_type = false)
{
if (!is_resource($this->link)) {
$this->init();
}
if (!$check_type)
{
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';
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');
@ -323,15 +337,14 @@ class sql_db
/**
* Return sql error array
*/
function sql_error ()
public function sql_error()
{
$return_ary = array(
'code' => '',
'message' => 'not connected',
);
if (is_resource($this->link))
{
if (is_resource($this->link)) {
$return_ary = array(
'code' => mysql_errno($this->link),
'message' => mysql_error($this->link),
@ -344,36 +357,33 @@ class sql_db
/**
* Close sql connection
*/
function close ()
{
if (is_resource($this->link))
public function close()
{
if (is_resource($this->link)) {
mysql_close($this->link);
}
$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 ()
public function query_info()
{
$info = array();
if ($num = $this->num_rows($this->result))
{
if ($num = $this->num_rows($this->result)) {
$info[] = "$num rows";
}
if (is_resource($this->link) AND $ext = mysql_info($this->link))
{
if (is_resource($this->link) and $ext = mysql_info($this->link)) {
$info[] = "$ext";
}
elseif (!$num && ($aff = $this->affected_rows($this->result) AND $aff != -1))
{
} elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) {
$info[] = "$aff rows";
}
@ -383,28 +393,24 @@ class sql_db
/**
* Store debug info
*/
function debug ($mode)
public function debug($mode)
{
if (!SQL_DEBUG) return;
if (!SQL_DEBUG) {
return;
}
if ($mode == 'start')
{
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
{
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)
{
} 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)
{
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'));
@ -421,19 +427,17 @@ class sql_db
/**
* Trigger error
*/
function trigger_error ($msg = '')
public function trigger_error($msg = '')
{
if (error_reporting())
{
if (!$msg) $msg = 'DB Error';
if (error_reporting()) {
if (!$msg) {
$msg = 'DB Error';
}
if (DBG_TRACKER === true)
{
if (DBG_TRACKER === true) {
$err = $this->sql_error();
$msg .= trim(sprintf(' #%06d %s', $err['code'], $err['message']));
}
else
{
} else {
$msg .= " [" . $this->debug_find_source() . "]";
}
@ -444,15 +448,13 @@ class sql_db
/**
* Find caller source
*/
function debug_find_source ()
public function debug_find_source()
{
$source = '';
$backtrace = debug_backtrace();
foreach ($backtrace as $trace)
{
if ($trace['file'] !== __FILE__)
{
foreach ($backtrace as $trace) {
if ($trace['file'] !== __FILE__) {
$source = str_replace(BB_PATH, '', $trace['file']) . '(' . $trace['line'] . ')';
break;
}
@ -464,10 +466,14 @@ class sql_db
/**
* Log error
*/
function log_error ()
public function log_error()
{
if (!SQL_LOG_ERRORS) return;
if (!error_reporting()) return;
if (!SQL_LOG_ERRORS) {
return;
}
if (!error_reporting()) {
return;
}
$msg = array();
$err = $this->sql_error();

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');

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.
*/
define('IN_TRACKER', true);
define('BB_ROOT', './../');
require(BB_ROOT . 'common.php');
if (!$tr_cfg['scrape']) msg_die('Please disable SCRAPE!');
if (!$tr_cfg['scrape']) {
msg_die('Please disable SCRAPE!');
}
// Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['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)
{
if (!isset($_GET['info_hash']) || strlen($_GET['info_hash']) != 20) {
msg_die('Invalid info_hash');
}
@ -21,7 +44,9 @@ $info_hash = $_GET['info_hash'];
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,

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');
@ -14,12 +37,9 @@ $forum_id = $t_data['forum_id'];
set_die_append_msg($forum_id, $topic_id);
if ($t_data['seeders'] > 2)
{
if ($t_data['seeders'] > 2) {
bb_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders']));
}
elseif ($t_data['call_seed_time'] > (TIMENOW - 86400))
{
} 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));
}
@ -28,8 +48,7 @@ $ban_user_id = array();
$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
foreach ($sql as $row)
{
foreach ($sql as $row) {
$ban_user_id[] = ',' . $row['ban_userid'];
}
$ban_user_id = join('', $ban_user_id);
@ -49,20 +68,17 @@ $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'))
{
if (bf($row['user_opt'], 'user_opt', 'user_callseed')) {
send_pm($row['user_id'], $subject, $message, BOT_UID);
}
}
}
else
{
} else {
send_pm($t_data['poster_id'], $subject, $message, BOT_UID);
}
@ -85,8 +101,7 @@ function topic_info ($topic_id)
WHERE tor.topic_id = $topic_id
";
if (!$torrent = DB()->fetch_row($sql))
{
if (!$torrent = DB()->fetch_row($sql)) {
bb_die($lang['TOPIC_POST_NOT_EXIST']);
}

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());
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();
@ -113,8 +151,7 @@ require(INC_DIR . 'datastore/xcache.php');
require(INC_DIR . 'datastore/file.php');
// Initialize datastore
switch ($bb_cfg['datastore_type'])
{
switch ($bb_cfg['datastore_type']) {
case 'memcache':
$datastore = new datastore_memcache($bb_cfg['cache']['memcache'], $bb_cfg['cache']['prefix']);
break;
@ -141,7 +178,8 @@ switch ($bb_cfg['datastore_type'])
break;
case 'filecache':
default: $datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']);
default:
$datastore = new datastore_file($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']);
}
function sql_dbg_enabled()
@ -154,10 +192,8 @@ function short_query ($sql, $esc_html = false)
$max_len = 100;
$sql = str_compact($sql);
if (!empty($_COOKIE['sql_log_full']))
{
if (mb_strlen($sql, 'UTF-8') > $max_len)
{
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);
}
}
@ -173,8 +209,7 @@ function utime ()
function bb_log($msg, $file_name)
{
if (is_array($msg))
{
if (is_array($msg)) {
$msg = join(LOG_LF, $msg);
}
$file_name .= (LOG_EXT) ? '.' . LOG_EXT : '';
@ -185,35 +220,29 @@ function file_write ($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $repla
{
$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];
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))
{
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)))
{
if (!$fp = @fopen($file, 'ab')) {
if ($dir_created = bb_mkdir(dirname($file))) {
$fp = @fopen($file, 'ab');
}
}
if ($fp)
{
if ($lock)
{
if ($fp) {
if ($lock) {
@flock($fp, LOCK_EX);
}
if ($replace_content)
{
if ($replace_content) {
@ftruncate($fp, 0);
@fseek($fp, 0, SEEK_SET);
}
@ -234,12 +263,9 @@ function bb_mkdir ($path, $mode = 0777)
function mkdir_rec($path, $mode)
{
if (is_dir($path))
{
if (is_dir($path)) {
return ($path !== '.' && $path !== '..') ? is_writable($path) : false;
}
else
{
} else {
return (mkdir_rec(dirname($path), $mode)) ? @mkdir($path, $mode) : false;
}
}
@ -302,8 +328,7 @@ function str_compact ($str)
function make_rand_str($len = 10)
{
$str = '';
while (strlen($str) < $len)
{
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);
@ -312,95 +337,64 @@ function make_rand_str ($len = 10)
// bencode: based on OpenTracker
function bencode($var)
{
if (is_string($var))
{
if (is_string($var)) {
return strlen($var) . ':' . $var;
}
else if (is_int($var))
{
} elseif (is_int($var)) {
return 'i' . $var . 'e';
}
else if (is_float($var))
{
} elseif (is_float($var)) {
return 'i' . sprintf('%.0f', $var) . 'e';
}
else if (is_array($var))
{
if (count($var) == 0)
{
} elseif (is_array($var)) {
if (count($var) == 0) {
return 'de';
}
else
{
} else {
$assoc = false;
foreach ($var as $key => $val)
{
if (!is_int($key))
{
foreach ($var as $key => $val) {
if (!is_int($key)) {
$assoc = true;
break;
}
}
if ($assoc)
{
if ($assoc) {
ksort($var, SORT_REGULAR);
$ret = 'd';
foreach ($var as $key => $val)
{
foreach ($var as $key => $val) {
$ret .= bencode($key) . bencode($val);
}
return $ret . 'e';
}
else
{
} else {
$ret = 'l';
foreach ($var as $val)
{
foreach ($var as $val) {
$ret .= bencode($val);
}
return $ret . 'e';
}
}
}
else
{
} else {
trigger_error('bencode error: wrong data type', E_USER_ERROR);
}
}
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)
{
if (is_array($var)) {
foreach ($var as $k => $v) {
if (is_array($v)) {
if ($one_dimensional) {
unset($var[$k]);
}
else if ($array_only)
{
} elseif ($array_only) {
$var[$k] = $fn($v);
}
else
{
} else {
array_deep($var[$k], $fn);
}
}
else if (!$array_only)
{
} elseif (!$array_only) {
$var[$k] = $fn($v);
}
}
}
else if (!$array_only)
{
} elseif (!$array_only) {
$var = $fn($var);
}
}
@ -412,8 +406,7 @@ function hide_bb_path ($path)
function sys($param)
{
switch ($param)
{
switch ($param) {
case 'la':
return function_exists('sys_getloadavg') ? join(' ', sys_getloadavg()) : 0;
break;
@ -456,8 +449,12 @@ function log_request ($file = '', $prepend_str = false, $add_post = true)
$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);
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'])) {
@ -470,19 +467,18 @@ function log_request ($file = '', $prepend_str = false, $add_post = true)
$str[] = $_SERVER['HTTP_REFERER'];
}
if (!empty($_POST) && $add_post) $str[] = "post: ". str_compact(urldecode(http_build_query($_POST)));
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'))
{
if (defined('IN_FORUM')) {
require(INC_DIR . 'init_bb.php');
}
// Tracker init
else if (defined('IN_TRACKER'))
{
} // 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)
@ -499,11 +495,9 @@ else if (defined('IN_TRACKER'))
header('Content-Type: text/plain');
header('Pragma: no-cache');
if (!defined('IN_ADMIN'))
{
if (!defined('IN_ADMIN')) {
// Exit if tracker is disabled via ON/OFF trigger
if (file_exists(BB_DISABLED))
{
if (file_exists(BB_DISABLED)) {
dummy_exit(mt_rand(60, 2400));
}
}

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('START_CRON', true);
define('BB_ROOT', dirname(__FILE__) . '/');

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">
<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>

103
dl.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('IN_FORUM', true);
define('BB_SCRIPT', 'dl');
@ -23,25 +46,20 @@ function send_file_to_browser($attachment, $upload_dir)
$gotit = false;
if (@!file_exists(@amod_realpath($filename)))
{
if (@!file_exists(@amod_realpath($filename))) {
bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']);
}
else
{
} 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'))
{
if (!strstr($attachment['mimetype'], 'image')) {
$attachment['mimetype'] = 'application/octet-stream';
}
//bt
if (!(isset($_GET['original']) && !IS_USER))
{
if (!(isset($_GET['original']) && !IS_USER)) {
include(INC_DIR . 'functions_torrent.php');
send_torrent_with_passkey($filename);
}
@ -58,17 +76,13 @@ function send_file_to_browser($attachment, $upload_dir)
unset($real_filename);
// Now send the File Contents to the Browser
if ($gotit)
{
if ($gotit) {
$size = @filesize($filename);
if ($size)
{
if ($size) {
header("Content-length: $size");
}
readfile($filename);
}
else
{
} else {
bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']);
}
@ -82,25 +96,21 @@ $user->session_start();
set_die_append_msg();
if (!$download_id)
{
if (!$download_id) {
bb_die($lang['NO_ATTACHMENT_SELECTED']);
}
if ($attach_config['disable_mod'] && !IS_ADMIN)
{
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;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachment information #1');
}
if (!($attachment = DB()->sql_fetchrow($result)))
{
if (!($attachment = DB()->sql_fetchrow($result))) {
bb_die($lang['ERROR_NO_ATTACHMENT']);
}
@ -113,24 +123,20 @@ $authorised = false;
$sql = 'SELECT * FROM ' . BB_ATTACHMENTS . ' WHERE attach_id = ' . (int)$attachment['attach_id'];
if (!($result = DB()->sql_query($sql)))
{
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++)
{
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)
{
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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query post information');
}
@ -143,15 +149,13 @@ for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++)
$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)
{
if (!$authorised) {
bb_die($lang['SORRY_AUTH_VIEW_ATTACH']);
}
@ -163,48 +167,39 @@ $datastore->rm('cat_forums');
$rows = get_extension_informations();
$num_rows = count($rows);
for ($i = 0; $i < $num_rows; $i++)
{
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)
{
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)
{
if ($thumbnail) {
$attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
}
// Update download count
if (!$thumbnail)
{
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))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not update attachment download count');
}
}
// Determine the 'presenting'-method
if ($download_mode == PHYSICAL_LINK)
{
if ($download_mode == PHYSICAL_LINK) {
$url = make_url($upload_dir . '/' . $attachment['physical_filename']);
header('Location: ' . $url);
exit;
}
else
{
if (IS_GUEST && !bb_captcha('check'))
{
} 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'] : '/');

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', 'dl_list');
@ -11,30 +34,20 @@ $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']))
{
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']))
{
} elseif (isset($_POST['dl_set_down'])) {
$new_dl_status = DL_STATUS_DOWN;
$dl_key = 'dld';
}
elseif (isset($_POST['dl_set_complete']))
{
} elseif (isset($_POST['dl_set_complete'])) {
$new_dl_status = DL_STATUS_COMPLETE;
$dl_key = 'dlc';
}
elseif (isset($_POST['dl_set_cancel']))
{
} elseif (isset($_POST['dl_set_cancel'])) {
$new_dl_status = DL_STATUS_CANCEL;
$dl_key = 'dla';
}
else
{
} else {
bb_die('Invalid download status');
}
}
@ -42,13 +55,10 @@ if ($mode == 'set_dl_status' || $mode == 'set_topics_dl_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')
{
if (isset($_POST['redirect_type']) && $_POST['redirect_type'] == 'search') {
$redirect_type = "search.php";
$redirect = ($full_url) ? $full_url : "$dl_key=1";
}
else
{
} 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");
}
@ -59,39 +69,32 @@ $user->session_start();
set_die_append_msg();
// Check if user logged in
if (!$userdata['session_logged_in'])
{
if (!$userdata['session_logged_in']) {
redirect(LOGIN_URL . "?redirect=$redirect_type&$redirect");
}
// Check if user did not confirm
if (isset($_POST['cancel']) && $_POST['cancel'])
{
if (isset($_POST['cancel']) && $_POST['cancel']) {
redirect("$redirect_type?$redirect");
}
// Delete DL-list
if ($mode == 'dl_delete' && $topic_id)
{
if (!IS_ADMIN)
{
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)))
{
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);
if (!$is_auth['auth_mod'])
{
if (!$is_auth['auth_mod']) {
bb_die($lang['NOT_MODERATOR']);
}
}
if (!$confirmed)
{
if (!$confirmed) {
$hidden_fields = array(
't' => $topic_id,
'mode' => 'dl_delete',
@ -112,40 +115,31 @@ if ($mode == 'dl_delete' && $topic_id)
$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']))
{
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)
{
foreach ($_POST['dl_topics_id_list'] as $topic_id) {
$req_topics_ary[] = (int)$topic_id;
}
}
elseif ($mode == 'set_dl_status')
{
} elseif ($mode == 'set_dl_status') {
$req_topics_ary[] = (int)$topic_id;
}
// Get existing topics
if ($req_topics_sql = join(',', $req_topics_ary))
{
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)
{
foreach (DB()->fetch_rowset($sql) as $row) {
$topics_ary[] = $row['topic_id'];
}
}
if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status'))
{
if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')) {
$new_dlstatus_ary = array();
foreach ($topics_ary as $topic_id)
{
foreach ($topics_ary as $topic_id) {
$new_dlstatus_ary[] = array(
'user_id' => (int)$user->id,
'topic_id' => (int)$topic_id,

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', 'feed');
@ -12,57 +35,51 @@ $type = isset($_POST['type']) ? $_POST['type'] : '';
$id = isset($_POST['id']) ? $_POST['id'] : 0;
$timecheck = TIMENOW - 600;
if (!$mode) bb_simple_die($lang['ATOM_NO_MODE']);
if (!$mode) {
bb_simple_die($lang['ATOM_NO_MODE']);
}
if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0)
{
if ($type == 'f')
{
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)
{
if (!$forum_data = DB()->fetch_row($sql)) {
if ($id == 0) {
$forum_data = array();
} else {
bb_simple_die($lang['ATOM_ERROR'] . ' #1');
}
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)
{
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
{
} 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 (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')
{
}
if ($type == 'u') {
// Check if the user has actually sent a user ID
if ($id < 1)
{
if ($id < 1) {
bb_simple_die($lang['ATOM_ERROR'] . ' #2');
}
if (!$username = get_username($id))
{
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)
{
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
{
} 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 (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
{
} else {
bb_simple_die($lang['ATOM_ERROR'] . ' #4');
}

256
group.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('IN_FORUM', true);
define('BB_SCRIPT', 'group');
@ -23,18 +46,18 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
$pm = ($bb_cfg['text_buttons']) ? '<a class="txtb" href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $lang['SEND_PM_TXTB'] . '</a>' : '<a href="' . (PM_URL . "?mode=post&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['SEND_PRIVATE_MESSAGE'] . '" title="' . $lang['SEND_PRIVATE_MESSAGE'] . '" border="0" /></a>';
$avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50);
if (bf($row['user_opt'], 'user_opt', 'user_viewemail') || $group_mod)
{
if (bf($row['user_opt'], 'user_opt', 'user_viewemail') || $group_mod) {
$email_uri = ($bb_cfg['board_email_form']) ? ("profile.php?mode=email&amp;" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email'];
$email = '<a class="editable" href="' . $email_uri . '">' . $row['user_email'] . '</a>';
} else {
$email = '';
}
else $email = '';
if ($row['user_website'])
{
if ($row['user_website']) {
$www = ($bb_cfg['text_buttons']) ? '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww">' . $lang['VISIT_WEBSITE_TXTB'] . '</a>' : '<a class="txtb" href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE'] . '" title="' . $lang['VISIT_WEBSITE'] . '" border="0" /></a>';
} else {
$www = '';
}
else $www = '';
return;
}
@ -52,21 +75,17 @@ $rel_limit = 50;
$group_info = array();
$is_moderator = false;
if ($group_id)
{
if (!$group_info = get_group_data($group_id))
{
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'])
{
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_id) {
// Show the main screen where the user can select a group.
$groups = array();
$pending = 10;
@ -100,34 +119,20 @@ if (!$group_id)
g.group_name ASC
";
foreach (DB()->fetch_rowset($sql) as $row)
{
if ($row['is_group_mod'])
{
foreach (DB()->fetch_rowset($sql) as $row) {
if ($row['is_group_mod']) {
$type = 'MOD';
}
else if ($row['membership'] == $member)
{
} elseif ($row['membership'] == $member) {
$type = 'MEMBER';
}
else if ($row['membership'] == $pending)
{
} elseif ($row['membership'] == $pending) {
$type = 'PENDING';
}
else if ($row['group_type'] == GROUP_OPEN)
{
} elseif ($row['group_type'] == GROUP_OPEN) {
$type = 'OPEN';
}
else if ($row['group_type'] == GROUP_CLOSED)
{
} elseif ($row['group_type'] == GROUP_CLOSED) {
$type = 'CLOSED';
}
else if ($row['group_type'] == GROUP_HIDDEN && IS_ADMIN)
{
} elseif ($row['group_type'] == GROUP_HIDDEN && IS_ADMIN) {
$type = 'HIDDEN';
}
else
{
} else {
continue;
}
@ -141,8 +146,7 @@ if (!$group_id)
global $lang;
$options = '';
foreach ($params as $name => $data)
{
foreach ($params as $name => $data) {
$text = htmlCHR(str_short(rtrim($name), HTML_SELECT_MAX_LENGTH));
$members = ($data['m']) ? $lang['MEMBERS_IN_GROUP'] . ': ' . $data['m'] : $lang['NO_GROUP_MEMBERS'];
@ -151,8 +155,7 @@ if (!$group_id)
$options .= '<li class="pad_2"><a href="' . GROUP_URL . $data['id'] . '" class="med bold">' . $text . '</a></li>';
$options .= ($data['rg']) ? '<ul><li class="med">' . $lang['RELEASE_GROUP'] . '</li>' : '<ul>';
$options .= '<li class="seedmed">' . $members . '</li>';
if (IS_AM)
{
if (IS_AM) {
$options .= '<li class="leechmed">' . $candidates . '</li>';
}
$options .= '</ul>';
@ -160,12 +163,10 @@ if (!$group_id)
return $options;
}
if ($groups)
{
if ($groups) {
$s_hidden_fields = '';
foreach ($groups as $type => $grp)
{
foreach ($groups as $type => $grp) {
$template->assign_block_vars('groups', array(
'MEMBERSHIP' => $lang["GROUP_MEMBER_{$type}"],
'GROUP_SELECT' => build_group($grp),
@ -178,20 +179,15 @@ if (!$group_id)
'S_USERGROUP_ACTION' => 'group.php',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
}
else
{
if(IS_ADMIN)
{
} else {
if (IS_ADMIN) {
redirect('admin/admin_groups.php');
}
else bb_die($lang['NO_GROUPS_EXIST']);
} else {
bb_die($lang['NO_GROUPS_EXIST']);
}
}
else if (isset($_POST['joingroup']) && $_POST['joingroup'])
{
if ($group_info['group_type'] != GROUP_OPEN)
{
} elseif (isset($_POST['joingroup']) && $_POST['joingroup']) {
if ($group_info['group_type'] != GROUP_OPEN) {
bb_die($lang['THIS_CLOSED_GROUP']);
}
@ -206,20 +202,17 @@ else if (isset($_POST['joingroup']) && $_POST['joingroup'])
$row = $moderator = DB()->fetch_row($sql);
if (!$row['group_id'])
{
if (!$row['group_id']) {
bb_die($lang['NO_GROUPS_EXIST']);
}
if ($row['user_id'])
{
if ($row['user_id']) {
set_die_append_msg(false, false, $group_id);
bb_die($lang['ALREADY_MEMBER_GROUP']);
}
add_user_into_group($group_id, $userdata['user_id'], 1, TIMENOW);
if ($bb_cfg['group_send_email'])
{
if ($bb_cfg['group_send_email']) {
require(CLASS_DIR . 'emailer.php');
$emailer = new emailer($bb_cfg['smtp_delivery']);
@ -241,37 +234,28 @@ else if (isset($_POST['joingroup']) && $_POST['joingroup'])
set_die_append_msg(false, false, $group_id);
bb_die($lang['GROUP_JOINED']);
}
else if (!empty($_POST['unsub']) || !empty($_POST['unsubpending']))
{
} elseif (!empty($_POST['unsub']) || !empty($_POST['unsubpending'])) {
delete_user_group($group_id, $userdata['user_id']);
set_die_append_msg(false, false, $group_id);
bb_die($lang['UNSUB_SUCCESS']);
}
else
{
} else {
// Handle Additions, removals, approvals and denials
$group_moderator = $group_info['group_moderator'];
if (!empty($_POST['add']) || !empty($_POST['remove']) || !empty($_POST['approve']) || !empty($_POST['deny']))
{
if (!$is_moderator)
{
if (!empty($_POST['add']) || !empty($_POST['remove']) || !empty($_POST['approve']) || !empty($_POST['deny'])) {
if (!$is_moderator) {
bb_die($lang['NOT_GROUP_MODERATOR']);
}
if (!empty($_POST['add']))
{
if (isset($_POST['username']) && !($row = get_userdata($_POST['username'], true)))
{
if (!empty($_POST['add'])) {
if (isset($_POST['username']) && !($row = get_userdata($_POST['username'], true))) {
bb_die($lang['COULD_NOT_ADD_USER']);
}
add_user_into_group($group_id, $row['user_id']);
if ($bb_cfg['group_send_email'])
{
if ($bb_cfg['group_send_email']) {
require(CLASS_DIR . 'emailer.php');
$emailer = new emailer($bb_cfg['smtp_delivery']);
@ -289,25 +273,19 @@ else
$emailer->send();
$emailer->reset();
}
}
else
{
if (((!empty($_POST['approve']) || !empty($_POST['deny'])) && !empty($_POST['pending_members'])) || (!empty($_POST['remove']) && !empty($_POST['members'])))
{
} else {
if (((!empty($_POST['approve']) || !empty($_POST['deny'])) && !empty($_POST['pending_members'])) || (!empty($_POST['remove']) && !empty($_POST['members']))) {
$members = (!empty($_POST['approve']) || !empty($_POST['deny'])) ? $_POST['pending_members'] : $_POST['members'];
$sql_in = array();
foreach ($members as $members_id)
{
foreach ($members as $members_id) {
$sql_in[] = (int)$members_id;
}
if (!$sql_in = join(',', $sql_in))
{
if (!$sql_in = join(',', $sql_in)) {
bb_die($lang['NONE_SELECTED']);
}
if (!empty($_POST['approve']))
{
if (!empty($_POST['approve'])) {
DB()->query("
UPDATE " . BB_USER_GROUP . " SET
user_pending = 0
@ -316,29 +294,24 @@ else
");
update_user_level($sql_in);
}
else if (!empty($_POST['deny']) || !empty($_POST['remove']))
{
} elseif (!empty($_POST['deny']) || !empty($_POST['remove'])) {
DB()->query("
DELETE FROM " . BB_USER_GROUP . "
WHERE user_id IN($sql_in)
AND group_id = $group_id
");
if (!empty($_POST['remove']))
{
if (!empty($_POST['remove'])) {
update_user_level($sql_in);
}
}
// Email users when they are approved
if (!empty($_POST['approve']) && $bb_cfg['group_send_email'])
{
if (!empty($_POST['approve']) && $bb_cfg['group_send_email']) {
$sql_select = "SELECT username, user_email, user_lang
FROM " . BB_USERS . "
WHERE user_id IN($sql_in)";
if (!$result = DB()->sql_query($sql_select))
{
if (!$result = DB()->sql_query($sql_select)) {
bb_die('Could not get user email information');
}
@ -347,8 +320,7 @@ else
$emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>");
foreach (DB()->fetch_rowset($sql_select) as $row)
{
foreach (DB()->fetch_rowset($sql_select) as $row) {
$emailer->use_template('group_approved', $row['user_lang']);
$emailer->email_address($row['username'] . " <{$row['user_email']}>");
}
@ -383,53 +355,37 @@ else
AND user_id = " . $userdata['user_id'] . "
LIMIT 1";
if ($row = DB()->fetch_row($sql))
{
if ($row['user_pending'] == 0)
{
if ($row = DB()->fetch_row($sql)) {
if ($row['user_pending'] == 0) {
$is_group_member = true;
}
else
{
} else {
$is_group_pending_member = true;
}
}
if ($userdata['user_id'] == $group_moderator['user_id'])
{
if ($userdata['user_id'] == $group_moderator['user_id']) {
$group_details = $lang['ARE_GROUP_MODERATOR'];
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
}
else if ($is_group_member || $is_group_pending_member)
{
} elseif ($is_group_member || $is_group_pending_member) {
$template->assign_vars(array(
'SHOW_UNSUBSCRIBE_CONTROLS' => true,
'CONTROL_NAME' => ($is_group_member) ? 'unsub' : 'unsubpending',
));
$group_details = ($is_group_pending_member) ? $lang['PENDING_THIS_GROUP'] : $lang['MEMBER_THIS_GROUP'];
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
}
else if (IS_GUEST)
{
} elseif (IS_GUEST) {
$group_details = $lang['LOGIN_TO_JOIN'];
$s_hidden_fields = '';
}
else
{
if ($group_info['group_type'] == GROUP_OPEN)
{
} else {
if ($group_info['group_type'] == GROUP_OPEN) {
$template->assign_var('SHOW_SUBSCRIBE_CONTROLS');
$group_details = $lang['THIS_OPEN_GROUP'];
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
}
else if ($group_info['group_type'] == GROUP_CLOSED)
{
} elseif ($group_info['group_type'] == GROUP_CLOSED) {
$group_details = $lang['THIS_CLOSED_GROUP'];
$s_hidden_fields = '';
}
else if ($group_info['group_type'] == GROUP_HIDDEN)
{
} elseif ($group_info['group_type'] == GROUP_HIDDEN) {
$group_details = $lang['THIS_HIDDEN_GROUP'];
$s_hidden_fields = '';
}
@ -442,16 +398,11 @@ else
generate_user_info($group_moderator, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
$group_type = '';
if ($group_info['group_type'] == GROUP_OPEN)
{
if ($group_info['group_type'] == GROUP_OPEN) {
$group_type = $lang['GROUP_OPEN'];
}
elseif ($group_info['group_type'] == GROUP_CLOSED)
{
} elseif ($group_info['group_type'] == GROUP_CLOSED) {
$group_type = $lang['GROUP_CLOSED'];
}
elseif ($group_info['group_type'] == GROUP_HIDDEN)
{
} elseif ($group_info['group_type'] == GROUP_HIDDEN) {
$group_type = $lang['GROUP_HIDDEN'];
}
@ -496,13 +447,11 @@ else
'S_GROUP_ACTION' => "group.php?" . POST_GROUPS_URL . "=$group_id",
));
switch ($view_mode)
{
switch ($view_mode) {
case 'releases':
// TODO Correct SQL to posts with attach and limit them, optimization
if (!$group_info['release_group'])
{
if (!$group_info['release_group']) {
set_die_append_msg(false, false, $group_id);
bb_die($lang['NOT_A_RELEASE_GROUP']);
}
@ -533,14 +482,12 @@ else
LIMIT $start, $per_page
";
if (!$releases = DB()->fetch_rowset($sql))
{
if (!$releases = DB()->fetch_rowset($sql)) {
set_die_append_msg(false, false, $group_id);
bb_die($lang['NO_SEARCH_MATCH']);
}
foreach ($releases as $i => $release)
{
foreach ($releases as $i => $release) {
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('releases', array(
@ -594,14 +541,12 @@ else
generate_pagination(GROUP_URL . $group_id, $count_members, $per_page, $start);
// Dump out the remaining users
foreach ($group_members as $i => $member)
{
foreach ($group_members as $i => $member) {
$user_id = $member['user_id'];
generate_user_info($member, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
if ($group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator)
{
if ($group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator) {
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('member', array(
@ -619,28 +564,24 @@ else
'TIME' => $user_time,
));
if ($is_moderator)
{
if ($is_moderator) {
$template->assign_block_vars('member.switch_mod_option', array());
}
}
}
// No group members
if (!$members_count)
{
if (!$members_count) {
$template->assign_block_vars('switch_no_members', array());
}
// No group members
if ($group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator)
{
if ($group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator) {
$template->assign_block_vars('switch_hidden_group', array());
}
// Pending
if ($is_moderator)
{
if ($is_moderator) {
$modgroup_pending_list = DB()->fetch_rowset("
SELECT u.username, u.avatar_ext_id, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email
FROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u
@ -653,10 +594,8 @@ else
$modgroup_pending_count = count($modgroup_pending_list);
}
if ($is_moderator && $modgroup_pending_list)
{
foreach ($modgroup_pending_list as $i => $member)
{
if ($is_moderator && $modgroup_pending_list) {
foreach ($modgroup_pending_list as $i => $member) {
$user_id = $member['user_id'];
generate_user_info($member, $bb_cfg['default_dateformat'], $is_moderator, $from, $posts, $joined, $pm, $email, $www, $user_time, $avatar);
@ -686,8 +625,7 @@ else
$template->assign_vars(array('MEMBERS' => true));
}
if ($is_moderator)
{
if ($is_moderator) {
$template->assign_block_vars('switch_mod_option', array());
$template->assign_block_vars('switch_add_member', array());
}

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', 'group_edit');
@ -17,37 +40,28 @@ $is_moderator = false;
$submit = !empty($_POST['submit']);
if ($group_id)
{
if (!$group_info = get_group_data($group_id))
{
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'])
{
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)
{
if ($is_moderator) {
// TODO Admin panel, some tasty features
// Avatar
if ($submit)
{
if (!empty($_FILES['avatar']['name']) && $bb_cfg['group_avatars']['up_allowed'])
{
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'])))
{
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
{
} else {
bb_die(implode($upload->errors));
}
@ -56,16 +70,11 @@ if ($is_moderator)
}
$group_type = '';
if ($group_info['group_type'] == GROUP_OPEN)
{
if ($group_info['group_type'] == GROUP_OPEN) {
$group_type = $lang['GROUP_OPEN'];
}
elseif ($group_info['group_type'] == GROUP_CLOSED)
{
} elseif ($group_info['group_type'] == GROUP_CLOSED) {
$group_type = $lang['GROUP_CLOSED'];
}
elseif ($group_info['group_type'] == GROUP_HIDDEN)
{
} elseif ($group_info['group_type'] == GROUP_HIDDEN) {
$group_type = $lang['GROUP_HIDDEN'];
}
@ -101,13 +110,10 @@ if ($is_moderator)
$template->pparse('body');
require(PAGE_FOOTER);
}
else
{
} else {
$redirect = 'index.php';
if ($group_id)
{
if ($group_id) {
$redirect = GROUP_URL . $group_id;
}
redirect($redirect);

170
index.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('IN_FORUM', true);
define('BB_SCRIPT', 'index');
@ -18,12 +41,10 @@ $datastore->enqueue(array(
'stats',
'moderators',
));
if ($bb_cfg['show_latest_news'])
{
if ($bb_cfg['show_latest_news']) {
$datastore->enqueue('latest_news');
}
if ($bb_cfg['show_network_news'])
{
if ($bb_cfg['show_network_news']) {
$datastore->enqueue('network_news');
}
@ -50,15 +71,13 @@ $tracking_topics = get_tracks('topic');
$tracking_forums = get_tracks('forum');
// Statistics
if (!$stats = $datastore->get('stats'))
{
if (!$stats = $datastore->get('stats')) {
$datastore->update('stats');
$stats = $datastore->get('stats');
}
// Forums data
if (!$forums = $datastore->get('cat_forums'))
{
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
@ -70,8 +89,7 @@ $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'])
{
if ($viewcat and !$viewcat =& $forums['c'][$viewcat]['cat_id']) {
redirect("index.php");
}
@ -125,41 +143,29 @@ $replace_in_parent = array(
);
$cache_name = 'index_sql_' . md5($sql);
if (!$cat_forums = CACHE('bb_cache')->get($cache_name))
{
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'])
{
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])
{
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)
{
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'])
{
if ($show_subforums && $row['show_on_index']) {
$parent['last_sf_id'] = $forum_id;
}
else
{
} else {
continue;
}
}
else
{
} else {
$f =& $forums['f'][$forum_id];
$row['forum_desc'] = $f['forum_desc'];
$row['forum_posts'] = $f['forum_posts'];
@ -174,25 +180,19 @@ if (!$cat_forums = CACHE('bb_cache')->get($cache_name))
// Obtain list of moderators
$moderators = array();
if (!$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)
{
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)
{
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>';
}
}
@ -203,8 +203,7 @@ $datastore->rm('moderators');
// Build index page
$forums_count = 0;
foreach ($cat_forums as $cid => $c)
{
foreach ($cat_forums as $cid => $c) {
$template->assign_block_vars('h_c', array(
'H_C_ID' => $cid,
'H_C_TITLE' => $cat_title_html[$cid],
@ -215,8 +214,7 @@ foreach ($cat_forums as $cid => $c)
'H_C_AL_MESS' => ($hide_cat_opt && !$showhide) ? true : false,
));
if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat)
{
if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) {
continue;
}
@ -226,10 +224,8 @@ foreach ($cat_forums as $cid => $c)
'U_VIEWCAT' => CAT_URL . $cid,
));
foreach ($c['f'] as $fid => $f)
{
if (!$fname_html =& $forum_name_html[$fid])
{
foreach ($c['f'] as $fid => $f) {
if (!$fname_html =& $forum_name_html[$fid]) {
continue;
}
$is_sf = $f['forum_parent'];
@ -238,13 +234,11 @@ foreach ($cat_forums as $cid => $c)
$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)
{
if ($f['forum_status'] == FORUM_LOCKED) {
$folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked'];
}
if ($is_sf)
{
if ($is_sf) {
$template->assign_block_vars('c.f.sf', array(
'SF_ID' => $fid,
'SF_NAME' => $fname_html,
@ -265,8 +259,7 @@ foreach ($cat_forums as $cid => $c)
'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'],
));
if ($f['last_post_id'])
{
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'],
@ -312,16 +305,13 @@ $template->assign_vars(array(
));
// Set tpl vars for bt_userdata
if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST)
{
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'))
{
if ($bb_cfg['show_latest_news']) {
if (!$latest_news = $datastore->get('latest_news')) {
$datastore->update('latest_news');
$latest_news = $datastore->get('latest_news');
}
@ -330,8 +320,7 @@ if ($bb_cfg['show_latest_news'])
'SHOW_LATEST_NEWS' => true,
));
foreach ($latest_news as $news)
{
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']),
@ -342,10 +331,8 @@ if ($bb_cfg['show_latest_news'])
}
// Network news
if ($bb_cfg['show_network_news'])
{
if (!$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');
}
@ -354,8 +341,7 @@ if ($bb_cfg['show_network_news'])
'SHOW_NETWORK_NEWS' => true,
));
foreach ($network_news as $net)
{
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']),
@ -365,18 +351,14 @@ if ($bb_cfg['show_network_news'])
}
}
if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
{
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'])
{
if ($stats['birthday_week_list']) {
shuffle($stats['birthday_week_list']);
foreach ($stats['birthday_week_list'] as $i => $week)
{
if ($i >= 5)
{
foreach ($stats['birthday_week_list'] as $i => $week) {
if ($i >= 5) {
$week_all = true;
continue;
}
@ -384,16 +366,14 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
}
$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']);
}
else $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
if ($stats['birthday_today_list'])
{
if ($stats['birthday_today_list']) {
shuffle($stats['birthday_today_list']);
foreach ($stats['birthday_today_list'] as $i => $today)
{
if ($i >= 5)
{
foreach ($stats['birthday_today_list'] as $i => $today) {
if ($i >= 5) {
$today_all = true;
continue;
}
@ -401,8 +381,9 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
}
$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'];
}
else $today_list = $lang['NOBIRTHDAY_TODAY'];
$template->assign_vars(array(
'WHOSBIRTHDAY_WEEK' => $week_list,
@ -411,12 +392,9 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
}
// Allow cron
if (IS_AM)
{
if (file_exists(CRON_RUNNING))
{
if (file_exists(CRON_ALLOWED))
{
if (IS_AM) {
if (file_exists(CRON_RUNNING)) {
if (file_exists(CRON_ALLOWED)) {
unlink(CRON_ALLOWED);
}
rename(CRON_RUNNING, CRON_ALLOWED);
@ -426,6 +404,8 @@ if (IS_AM)
// 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');

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', 'info');
define('BB_ROOT', './');
@ -13,8 +36,7 @@ $info = array();
$html_dir = LANG_DIR . 'html/';
$req_mode = !empty($_REQUEST['show']) ? (string)$_REQUEST['show'] : 'not_found';
switch ($req_mode)
{
switch ($req_mode) {
case 'advert':
$info['title'] = $lang['ADVERT'];
$info['src'] = 'advert.html';
@ -50,12 +72,23 @@ $require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $h
</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-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-body p { margin-top: 1em; margin-bottom: 1em; }
</style>
<br/>
<div id="infobox-wrap" class="bCenter row1">
@ -65,7 +98,8 @@ $require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $h
<?php require($require); ?>
</div>
</fieldset>
<p class="gen tRight pad_6"><a href="javascript:window.close();" class="gen">[ <?php echo $lang['LOCK']; ?> ]</a></p>
<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,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.
*/
// TorrentPier bridge
define('TP_ROOT', './../ptv/'); // Absolete or related local path to your TorrentPier installation
@ -17,8 +40,7 @@ require_once('./include/core_announce.php');
$passkey = @$_GET['passkey'];
if (!$passkey)
{
if (!$passkey) {
err('Passkey required');
}
@ -26,8 +48,7 @@ dbconn();
$res = mysql_query("SELECT id FROM users WHERE passkey = " . sqlesc($passkey)) or err(mysql_error());
if (mysql_affected_rows() == 0)
{
if (mysql_affected_rows() == 0) {
err('Invalid passkey! Re-download the .torrent from ' . $DEFAULTBASEURL);
}
@ -45,8 +66,7 @@ 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)
{
if (mysql_affected_rows() == 0) {
err('Passkey doesn\'t created on new tracker or user doesn\'t exist');
}

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");
@ -15,8 +38,7 @@ $msg = '[b]Внимание![/b] Наш трекер переехал на но
[b]Пароль:[/b] %s
Сменить пароль можно после входа на трекер в [url=' . $new_tr_url . 'profile.php?mode=editprofile]настройках[/url].';
if (empty($_POST['confirm']))
{
if (empty($_POST['confirm'])) {
stdhead();
echo '
<br />
@ -26,15 +48,14 @@ if (empty($_POST['confirm']))
</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)
{
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) . ")");
}

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', './');
@ -10,7 +33,9 @@ require(BB_ROOT . 'converter/functions.php');
// Start session management
$user->session_start();
if (!IS_ADMIN) die("Restricted access");
if (!IS_ADMIN) {
die("Restricted access");
}
while (@ob_end_flush()) ;
ob_implicit_flush();
@ -29,8 +54,7 @@ error_reporting(E_ALL);
<?php
if (empty($_POST['confirm']))
{
if (empty($_POST['confirm'])) {
echo '
<br />
<center>
@ -42,18 +66,13 @@ if (empty($_POST['confirm']))
';
exit;
}
else
{
} 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)
{
if (CONVERT_USERS) {
if (CLEAN) {
tp_users_cleanup();
print_ok("Users cleared");
}
@ -65,8 +84,7 @@ if (CONVERT_USERS)
$loops = (int)ceil($users_count / C_USERS_PER_ONCE);
$pass = array();
switch(TR_TYPE)
{
switch (TR_TYPE) {
case 'yse':
$_sql = 'avatar, ';
break;
@ -76,8 +94,7 @@ if (CONVERT_USERS)
break;
}
for ($i = 0; $i < $loops; $i++)
{
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_USERS_PER_ONCE;
$offset = C_USERS_PER_ONCE;
@ -93,8 +110,7 @@ if (CONVERT_USERS)
$users = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($users as $user)
{
foreach ($users as $user) {
$user['id'] += $max_uid;
$user['password'] = make_rand_str(15);
convert_user($user);
@ -116,13 +132,11 @@ if (CONVERT_USERS)
unset($users, $pass, $to_write);
}
if (CONVERT_TORRENTS)
{
if (CONVERT_TORRENTS) {
require_once(INC_DIR . 'functions_post.php');
require_once(INC_DIR . 'bbcode.php');
if (CLEAN)
{
if (CLEAN) {
tp_categories_cleanup();
tp_forums_cleanup();
tp_topics_cleanup();
@ -148,8 +162,7 @@ if (CONVERT_TORRENTS)
$max_forum_id = (int)get_max_val(BB_FORUMS, 'forum_id');
foreach ($cats as $cat)
{
foreach ($cats as $cat) {
$cat['id'] += $max_forum_id;
$cat['cat_id'] = $tr_cat_id;
convert_cat($cat);
@ -159,8 +172,7 @@ if (CONVERT_TORRENTS)
unset($cats);
// Start of torrents converting
switch(TR_TYPE)
{
switch (TR_TYPE) {
case 'yse':
$_sql = 'image1, image2, ';
break;
@ -181,8 +193,7 @@ if (CONVERT_TORRENTS)
$torrents_count = (int)get_count(TB_TORRENTS_TABLE, 'id');
$loops = (int)ceil($torrents_count / C_TORRENTS_PER_ONCE);
for ($i = 0; $i < $loops; $i++)
{
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
$sql = "
@ -197,8 +208,7 @@ if (CONVERT_TORRENTS)
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($torrents as $torrent)
{
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;
@ -213,8 +223,7 @@ if (CONVERT_TORRENTS)
print_ok("Total $torrents_count torrents from TBDev converted");
unset($torrents);
if (CONVERT_COMMENTS)
{
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');
@ -222,8 +231,7 @@ if (CONVERT_TORRENTS)
$comments_count = (int)get_count(TB_COMMENTS_TABLE, 'id');
$loops = (int)ceil($comments_count / C_COMMENTS_PER_ONCE);
for ($i = 0; $i < $loops; $i++)
{
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_COMMENTS_PER_ONCE;
$offset = C_COMMENTS_PER_ONCE;
$sql = "
@ -239,8 +247,7 @@ if (CONVERT_TORRENTS)
$comments = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($comments as $comment)
{
foreach ($comments as $comment) {
$comment['user'] += $max_uid;
$comment['id'] += $max_post_id;
convert_comment($comment);
@ -258,4 +265,5 @@ if (CONVERT_TORRENTS)
Converting completed.
</body>
</html>
<?php } ?>
<?php
} ?>

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('EXCLUDED_USERS_CSV')) { define('EXCLUDED_USERS_CSV', join(',', array(GUEST_UID, BOT_UID,))); }
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');

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.
*/
function print_ok($sql)
{
@ -16,7 +39,9 @@ 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)})); }
for ($a = 0; $a < strlen($h); $a += 2) {
$r .= chr(hexdec($h{$a} . $h{($a + 1)}));
}
return $r;
}
@ -34,8 +59,7 @@ function get_count($table_name, $column)
function set_auto_increment($table_name, $column, $val = null)
{
if (empty($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;
@ -52,8 +76,7 @@ function tp_users_cleanup()
function tp_user_level($tb_class)
{
switch($tb_class)
{
switch ($tb_class) {
case 0:
case 1:
case 2:
@ -96,8 +119,7 @@ function convert_user($user)
$columns = $values = array();
foreach ($user_data as $column => $value)
{
foreach ($user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -114,8 +136,7 @@ function convert_user($user)
);
$columns = $values = array();
foreach ($bt_user_data as $column => $value)
{
foreach ($bt_user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -142,8 +163,7 @@ function tp_add_category($cat_data)
{
$columns = $values = array();
foreach ($cat_data as $column => $value)
{
foreach ($cat_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -170,8 +190,7 @@ function tp_topics_cleanup()
function tp_add_topic($topic_data)
{
$columns = $values = array();
foreach ($topic_data as $column => $value)
{
foreach ($topic_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -184,11 +203,9 @@ function tp_add_topic($topic_data)
function tp_add_post($post_data)
{
foreach ($post_data as $key => $data)
{
foreach ($post_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value)
{
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -202,11 +219,9 @@ function tp_add_post($post_data)
function tp_add_attach($attach_data)
{
foreach ($attach_data as $key => $data)
{
foreach ($attach_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value)
{
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -228,31 +243,24 @@ function make_img_path ($name)
function append_images($tor)
{
$poster = $screens = '';
switch(TR_TYPE)
{
switch (TR_TYPE) {
case 'yse':
if (!empty($tor['image1']))
{
if (!empty($tor['image1'])) {
$poster = "[img=right]" . make_img_path($tor['image1']) . "[/img]";
}
if (!empty($tor['image2']))
{
if (!empty($tor['image2'])) {
$screens = '[spoiler="Скриншоты"][img]' . make_img_path($tor['image2']) . "[/img][/spoiler]";
}
break;
case 'sky':
if (!empty($tor['poster']))
{
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)
{
if ($has_screens) {
$screens .= '[spoiler="Скриншоты"]';
for ($i = 1; $i <= 4; $i++)
{
if (!empty($tor['screenshot'.$i]))
{
for ($i = 1; $i <= 4; $i++) {
if (!empty($tor['screenshot' . $i])) {
$screens .= "[img]" . make_img_path($tor['screenshot' . $i]) . "[/img] \n";
}
}
@ -322,11 +330,9 @@ function convert_torrent($torrent)
tp_add_attach($attach_data);
//Torrents
if (BDECODE)
{
if (BDECODE) {
$filename = get_attachments_dir() . '/' . $torrent['id'] . ".torrent";
if (!file_exists($filename))
{
if (!file_exists($filename)) {
return;
}
if (!function_exists('bdecode_file')) include_once(INC_DIR . 'functions_torrent.php');
@ -334,9 +340,7 @@ function convert_torrent($torrent)
$info = ($tor['info']) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
}
else
{
} else {
$info_hash_sql = hex2bin($torrent['info_hash']);
}
@ -355,8 +359,7 @@ function convert_torrent($torrent)
$columns = $values = array();
foreach ($torrent_data as $column => $value)
{
foreach ($torrent_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . $db->escape($value) . "'";
}
@ -411,8 +414,7 @@ function convert_cat($forum, $allow_torrents = true)
$columns = $values = array();
foreach ($forum_data as $column => $value)
{
foreach ($forum_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}

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();

View file

@ -1,4 +1,28 @@
<?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)
// Options

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', './');
@ -25,8 +48,7 @@ ob_implicit_flush();
<?php
if (empty($_POST['confirm']))
{
if (empty($_POST['confirm'])) {
echo '
<br />
<center>
@ -38,10 +60,7 @@ if (empty($_POST['confirm']))
';
exit;
}
else
{
} else {
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
@ -52,8 +71,7 @@ $not_exist = array();
$attach_dir = get_attachments_dir() . '/';
for ($i = 0; $i < $loops; $i++)
{
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
@ -67,15 +85,11 @@ for ($i = 0; $i < $loops; $i++)
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($torrents as $torrent)
{
foreach ($torrents as $torrent) {
$filename = $attach_dir . $torrent['physical_filename'];
if (!file_exists($filename))
{
if (!file_exists($filename)) {
$not_exist[] = '<a href="viewtopic.php?t=' . $torrent['topic_id'] . '">' . $filename . '</a>';
}
else
{
} else {
$tor = bdecode_file($filename);
$info = (!empty($tor['info'])) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
@ -90,9 +104,7 @@ for ($i = 0; $i < $loops; $i++)
print_ok("Completed");
if (!empty($not_exist))
{
if (!empty($not_exist)) {
print_ok("These torrents doesn't exist in filesystem: " . implode(', ', array_unique($not_exist)));
}
}

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('EXCLUDED_USERS_CSV')) { define('EXCLUDED_USERS_CSV', join(',', array(GUEST_UID, BOT_UID,))); }
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');

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.
*/
function print_ok($sql)
{
@ -16,7 +39,9 @@ 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)})); }
for ($a = 0; $a < strlen($h); $a += 2) {
$r .= chr(hexdec($h{$a} . $h{($a + 1)}));
}
return $r;
}
@ -34,8 +59,7 @@ function get_count($table_name, $column)
function set_auto_increment($table_name, $column, $val = null)
{
if (empty($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;
@ -52,8 +76,7 @@ function tp_users_cleanup()
function tp_user_level($tb_class)
{
switch($tb_class)
{
switch ($tb_class) {
case 0:
case 1:
case 2:
@ -101,8 +124,7 @@ function convert_user($user)
$columns = $values = array();
foreach ($user_data as $column => $value)
{
foreach ($user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -119,8 +141,7 @@ function convert_user($user)
);
$columns = $values = array();
foreach ($bt_user_data as $column => $value)
{
foreach ($bt_user_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -147,8 +168,7 @@ function tp_add_category($cat_data)
{
$columns = $values = array();
foreach ($cat_data as $column => $value)
{
foreach ($cat_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -175,8 +195,7 @@ function tp_topics_cleanup()
function tp_add_topic($topic_data)
{
$columns = $values = array();
foreach ($topic_data as $column => $value)
{
foreach ($topic_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -189,11 +208,9 @@ function tp_add_topic($topic_data)
function tp_add_post($post_data)
{
foreach ($post_data as $key => $data)
{
foreach ($post_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value)
{
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -207,11 +224,9 @@ function tp_add_post($post_data)
function tp_add_attach($attach_data)
{
foreach ($attach_data as $key => $data)
{
foreach ($attach_data as $key => $data) {
$columns = $values = array();
foreach ($data as $column => $value)
{
foreach ($data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -233,31 +248,24 @@ function make_img_path ($name)
function append_images($tor)
{
$poster = $screens = '';
switch(TR_TYPE)
{
switch (TR_TYPE) {
case 'yse':
if (!empty($tor['image1']))
{
if (!empty($tor['image1'])) {
$poster = "[img=right]" . make_img_path($tor['image1']) . "[/img]";
}
if (!empty($tor['image2']))
{
if (!empty($tor['image2'])) {
$screens = '[spoiler="Скриншоты"][img]' . make_img_path($tor['image2']) . "[/img][/spoiler]";
}
break;
case 'sky':
if (!empty($tor['poster']))
{
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)
{
if ($has_screens) {
$screens .= '[spoiler="Скриншоты"]';
for ($i = 1; $i <= 4; $i++)
{
if (!empty($tor['screenshot'.$i]))
{
for ($i = 1; $i <= 4; $i++) {
if (!empty($tor['screenshot' . $i])) {
$screens .= "[img]" . make_img_path($tor['screenshot' . $i]) . "[/img] \n";
}
}
@ -328,11 +336,9 @@ function convert_torrent($torrent)
tp_add_attach($attach_data);
//Torrents
if (BDECODE)
{
if (BDECODE) {
$filename = get_attachments_dir() . '/' . $torrent['id'] . ".torrent";
if (!file_exists($filename))
{
if (!file_exists($filename)) {
return;
}
if (!function_exists('bdecode_file')) include_once('./includes/functions_torrent.php');
@ -340,9 +346,7 @@ function convert_torrent($torrent)
$info = ($tor['info']) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
}
else
{
} else {
$info_hash_sql = hex2bin($torrent['info_hash']);
}
@ -361,8 +365,7 @@ function convert_torrent($torrent)
$columns = $values = array();
foreach ($torrent_data as $column => $value)
{
foreach ($torrent_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}
@ -417,8 +420,7 @@ function convert_cat($forum, $allow_torrents = true)
$columns = $values = array();
foreach ($forum_data as $column => $value)
{
foreach ($forum_data as $column => $value) {
$columns[] = $column;
$values[] = "'" . DB()->escape($value) . "'";
}

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();

View file

@ -1,4 +1,28 @@
<?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)
// Options

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', './');
@ -24,8 +47,7 @@ ob_implicit_flush();
<?php
if (empty($_POST['confirm']))
{
if (empty($_POST['confirm'])) {
echo '
<br />
<center>
@ -37,10 +59,7 @@ if (empty($_POST['confirm']))
';
exit;
}
else
{
} else {
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', @ini_get('max_execution_time') + 1200);
@ -51,8 +70,7 @@ $not_exist = array();
$attach_dir = get_attachments_dir() . '/';
for ($i = 0; $i < $loops; $i++)
{
for ($i = 0; $i < $loops; $i++) {
$start = $i * C_TORRENTS_PER_ONCE;
$offset = C_TORRENTS_PER_ONCE;
@ -66,15 +84,11 @@ for ($i = 0; $i < $loops; $i++)
$torrents = DB()->fetch_rowset($sql);
DB()->sql_freeresult();
foreach ($torrents as $torrent)
{
foreach ($torrents as $torrent) {
$filename = $attach_dir . $torrent['physical_filename'];
if (!file_exists($filename))
{
if (!file_exists($filename)) {
$not_exist[] = '<a href="viewtopic.php?t=' . $torrent['topic_id'] . '">' . $filename . '</a>';
}
else
{
} else {
$tor = bdecode_file($filename);
$info = (!empty($tor['info'])) ? $tor['info'] : array();
$info_hash = pack('H*', sha1(bencode($info)));
@ -89,9 +103,7 @@ for ($i = 0; $i < $loops; $i++)
print_ok("Completed");
if (!empty($not_exist))
{
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,7 +30,9 @@ 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', '');
@ -17,8 +42,7 @@ if ($confirm) {
$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)
{
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'] . "");
}

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,7 +30,9 @@ 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', '');

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,7 +30,9 @@ 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', '');

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,7 +36,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']);
}
$confirm = request_var('confirm', '');
@ -51,7 +76,7 @@ if ($confirm) {
);
$upload = new upload_common();
if ($upload->init($bb_cfg['avatars'], $FILE, false) AND $upload->store('avatar', $row)) {
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 {

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']);
}
$confirm = request_var('confirm', '');

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

View file

@ -1,24 +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 (!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'];
if (!$user_id OR !$u_data = get_userdata($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)
{
if (!IS_ADMIN && $user_id != $user->id) {
$this->ajax_die($lang['NOT_ADMIN']);
}
switch ($mode)
{
switch ($mode) {
case 'delete':
delete_avatar($user_id, $u_data['avatar_ext_id']);
$new_ext_id = 0;

View file

@ -1,16 +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']);
}
$attach_id = (int)$this->request['attach_id'];
$mode = (string)$this->request['mode'];
if ($bb_cfg['tor_comment'])
{
if ($bb_cfg['tor_comment']) {
$comment = (string)$this->request['comment'];
}
@ -24,46 +50,48 @@ $tor = DB()->fetch_row("
LIMIT 1
");
if (!$tor) $this->ajax_die($lang['TORRENT_FAILED']);
if (!$tor) {
$this->ajax_die($lang['TORRENT_FAILED']);
}
switch ($mode)
{
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 (!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)
{
if ($tor['tor_status'] == $new_status) {
$this->ajax_die($lang['TOR_STATUS_DUB']);
}
// Запрет на изменение/присвоение CH-статуса модератором
if ($new_status == TOR_CLOSED_CPHOLD && !IS_ADMIN)
{
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");
if ($tor['tor_status'] == TOR_CLOSED_CPHOLD) {
if (!IS_ADMIN) {
$this->verify_mod_rights($tor['forum_id']);
}
else
{
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']))
{
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'] . '?';
@ -75,14 +103,14 @@ switch ($mode)
$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)
{
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;
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']);
@ -91,12 +119,16 @@ switch ($mode)
break;
case 'status_reply':
if (!$bb_cfg['tor_comment']) $this->ajax_die($lang['MODULE_OFF']);
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;
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']);

View file

@ -1,15 +1,38 @@
<?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']))
{
if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
if (!isset($this->request['type']))
{
if (!isset($this->request['type'])) {
$this->ajax_die('type');
}
$attach_id = (int)$this->request['attach_id'];
@ -36,40 +59,30 @@ $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;
if (!$torrent) {
$this->ajax_die($lang['INVALID_ATTACH_ID']);
}
else
{
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)
{
} elseif (!IS_AM) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
$title = $url = '';
switch ($type)
{
switch ($type) {
case 'set_gold';
case 'set_silver';
case 'unset_silver_gold';
if ($type == 'set_silver')
{
if ($type == 'set_silver') {
$tor_type = TOR_TYPE_SILVER;
}
elseif ($type == 'set_gold')
{
} elseif ($type == 'set_gold') {
$tor_type = TOR_TYPE_GOLD;
}
else
{
} else {
$tor_type = 0;
}
change_tor_type($attach_id, $tor_type);
@ -88,13 +101,17 @@ switch ($type)
break;
case 'del_torrent';
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['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']);
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;

View file

@ -1,26 +1,47 @@
<?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'];
$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))
{
if (!$user_id or !$u_data = get_userdata($user_id)) {
$this->ajax_die('invalid user_id');
}
if (!is_array($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]))
{
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]));
}
}

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 $datastore, $lang;
$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))
{
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]))
{
if ($rank_id != 0 && !isset($ranks[$rank_id])) {
$this->ajax_die("invalid rank_id: $rank_id");
}

View file

@ -1,27 +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 $bb_cfg, $userdata, $lang;
if (!$group_id = intval($this->request['group_id']) OR !$group_info = get_group_data($group_id))
{
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'])
{
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;
if (!IS_ADMIN && $userdata['user_id'] != $group_info['group_moderator'])
{
if (!IS_ADMIN && $userdata['user_id'] != $group_info['group_moderator']) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
switch ($mode)
{
switch ($mode) {
case 'group_name':
case 'group_signature':
case 'group_description':

View file

@ -1,28 +1,49 @@
<?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))
{
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'])
{
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;
switch ($field)
{
switch ($field) {
case 'username':
require_once(INC_DIR . 'functions_validate.php');
$value = clean_username($value);
if ($err = validate_username($value))
{
if ($err = validate_username($value)) {
$this->ajax_die(strip_tags($err));
}
$this->response['new_value'] = $this->request['value'];
@ -31,46 +52,43 @@ switch ($field)
case 'user_email':
require_once(INC_DIR . 'functions_validate.php');
$value = htmlCHR($value);
if ($err = validate_email($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))
{
if ($value == '' || preg_match('#^https?://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+$#iu', $value)) {
$this->response['new_value'] = htmlCHR($value);
} else {
$this->ajax_die($lang['WEBSITE_ERROR']);
}
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']);
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];
}
else $this->response['new_value'] = $lang['GENDER_SELECT'][$value];
break;
case 'user_birthday':
if (!$bb_cfg['birthday_enabled']) $this->ajax_die($lang['MODULE_OFF']);
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)
{
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'])
{
} 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'])
{
} 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']));
}
}
@ -79,24 +97,21 @@ switch ($field)
break;
case 'user_icq':
if ($value && !preg_match('#^\d{6,15}$#', $value))
{
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))
{
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))
{
if ($value && !preg_match("#^[a-zA-Z0-9_]{1,15}$#", $value)) {
$this->ajax_die($lang['TWITTER_ERROR']);
}
$this->response['new_value'] = $this->request['value'];
@ -112,8 +127,7 @@ switch ($field)
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)
{
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);
@ -123,15 +137,15 @@ switch ($field)
case 'u_down_total':
case 'u_up_release':
case 'u_up_bonus':
if (!IS_ADMIN) $this->ajax_die($lang['NOT_ADMIN']);
if (!IS_ADMIN) {
$this->ajax_die($lang['NOT_ADMIN']);
}
$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)
{
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;
}
@ -139,8 +153,7 @@ switch ($field)
$value = sprintf('%.0f', $value);
$this->response['new_value'] = humn_size($value, null, null, ' ');
if (!$btu = get_bt_userdata($user_id))
{
if (!$btu = get_bt_userdata($user_id)) {
require(INC_DIR . 'functions_torrent.php');
generate_passkey($user_id, true);
$btu = get_bt_userdata($user_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'];
if ($req_uid == $userdata['user_id'] || IS_ADMIN)
{
if (empty($this->request['confirmed']))
{
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))
{
if (!$passkey = generate_passkey($req_uid, IS_ADMIN)) {
$this->ajax_die('Could not insert passkey');
}
tracker_rm_user($req_uid);
$this->response['passkey'] = $passkey;
} else {
$this->ajax_die($lang['NOT_AUTHORISED']);
}
else $this->ajax_die($lang['NOT_AUTHORISED']);

View file

@ -1,21 +1,43 @@
<?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))
{
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'])
{
if (!$mode = (string)$this->request['mode']) {
$this->ajax_die('invalid mode (empty)');
}
switch ($mode)
{
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
@ -26,27 +48,21 @@ switch ($mode)
ORDER BY g.group_name
";
$html = array();
foreach (DB()->fetch_rowset($sql) as $row)
{
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)
{
if (IS_ADMIN) {
$href .= "&amp;u=$user_id";
$link = '<a href="' . $href . '" class="' . $class . '" target="_blank">' . htmlCHR($row['group_name']) . '</a>';
$html[] = $link;
}
else
{
} else {
// скрытая группа и сам юзер не является ее членом
if ($row['group_type'] == GROUP_HIDDEN && !$row['can_view'])
{
if ($row['group_type'] == GROUP_HIDDEN && !$row['can_view']) {
continue;
}
if ($row['group_moderator'] == $user->id)
{
if ($row['group_moderator'] == $user->id) {
$class .= ' selfMod';
$href .= "&amp;u=$user_id"; // сам юзер модератор этой группы
}
@ -54,12 +70,9 @@ switch ($mode)
$html[] = $link;
}
}
if ($html)
{
if ($html) {
$this->response['group_list_html'] = '<ul><li>' . join('</li><li>', $html) . '</li></ul>';
}
else
{
} else {
$this->response['group_list_html'] = $lang['GROUP_LIST_HIDDEN'];
}
break;

View file

@ -1,29 +1,52 @@
<?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'];
$html = '';
switch($mode)
{
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)
{
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']);
}
else $html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']);
break;
case 'birthday_today':
@ -32,15 +55,14 @@ switch($mode)
'stats',
));
if ($stats['birthday_today_list'])
{
foreach($stats['birthday_today_list'] as $today)
{
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'];
}
else $html = $lang['NOBIRTHDAY_TODAY'];
break;
case 'get_forum_mods':
@ -53,18 +75,14 @@ switch($mode)
$moderators = array();
$mod = $datastore->get('moderators');
if (isset($mod['mod_users'][$forum_id]))
{
foreach ($mod['mod_users'][$forum_id] as $user_id)
{
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)
{
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>';
}
}
@ -77,10 +95,13 @@ switch($mode)
case 'change_tz':
$tz = (int)$this->request['tz'];
if ($tz < -12) $tz = -12;
if ($tz > 13) $tz = 13;
if ($tz != $bb_cfg['board_timezone'])
{
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;

View file

@ -1,19 +1,41 @@
<?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'];
switch ($mode)
{
switch ($mode) {
case 'clear_cache':
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val)
{
if (!in_array('db_sqlite', $cache_val))
{
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) {
if (!in_array('db_sqlite', $cache_val)) {
CACHE($cache_name)->rm();
}
}
@ -40,10 +62,8 @@ switch ($mode)
$match_len = strlen($match);
$dir = $template->cachedir;
$res = @opendir($dir);
while (($file = readdir($res)) !== false)
{
if (substr($file, 0, $match_len) === $match)
{
while (($file = readdir($res)) !== false) {
if (substr($file, 0, $match_len) === $match) {
@unlink($dir . $file);
}
}
@ -57,15 +77,13 @@ switch ($mode)
exec("indexer --config {$bb_cfg['sphinx_config_path']} --all --rotate", $result);
if (!is_file($bb_cfg['sphinx_config_path'].".log"))
{
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);
foreach ($result as $row)
{
foreach ($result as $row) {
file_put_contents($bb_cfg['sphinx_config_path'] . ".log", $row . "\r\n", FILE_APPEND);
}

View file

@ -1,65 +1,103 @@
<?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'];
$user_id = $this->request['user_id'];
switch ($mode)
{
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)
{
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']);
}
else $this->ajax_die($lang['USER_DELETE_CSV']);
break;
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)
{
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']);
}
else $this->ajax_die($lang['NOT_ADMIN']);
break;
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)
{
if (IS_ADMIN) {
post_delete('user', $user_id);
$this->response['info'] = $lang['USER_DELETED_POSTS'];
} else {
$this->ajax_die($lang['NOT_ADMIN']);
}
else $this->ajax_die($lang['NOT_ADMIN']);
break;
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);
@ -69,8 +107,12 @@ switch ($mode)
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);

View file

@ -1,27 +1,49 @@
<?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'];
switch ($mode)
{
switch ($mode) {
case 'tor_status':
$topics = (string)$this->request['topic_ids'];
$status = (int)$this->request['status'];
// Валидность статуса
if (!isset($lang['TOR_STATUS_NAME'][$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');
foreach($topic_ids as $attach_id)
{
foreach ($topic_ids as $attach_id) {
change_tor_status($attach_id, $status);
}
$this->response['status'] = $bb_cfg['tor_icons'][$status];
@ -33,11 +55,14 @@ switch ($mode)
$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"))
{
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']);
@ -48,15 +73,13 @@ switch ($mode)
// Обновление кеша новостей на главной
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));
if (isset($news_forums[$t_data['forum_id']]) && $bb_cfg['show_latest_news'])
{
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'])
{
if (isset($net_forums[$t_data['forum_id']]) && $bb_cfg['show_network_news']) {
$datastore->enqueue('network_news');
$datastore->update('network_news');
}
@ -69,7 +92,9 @@ switch ($mode)
$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 . "
WHERE user_reg_ip = '{$profiledata['user_reg_ip']}'
@ -84,28 +109,25 @@ switch ($mode)
$link_reg_ip = $link_last_ip = '';
if (!empty($reg_ip))
{
if (!empty($reg_ip)) {
$link_reg_ip .= $lang['OTHER_IP'] . ' ';
foreach ($reg_ip as $row)
{
foreach ($reg_ip as $row) {
$link_reg_ip .= profile_url($row) . ' ';
}
}
if (!empty($last_ip))
{
if (!empty($last_ip)) {
$link_last_ip .= $lang['OTHER_IP'] . ' ';
foreach ($last_ip as $row)
{
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
{
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>';

View file

@ -1,13 +1,40 @@
<?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']);
if (!$mc_text = prepare_message($mc_text)) {
$this->ajax_die($lang['EMPTY_MESSAGE']);
}
$post = DB()->fetch_row("
SELECT
@ -15,7 +42,9 @@ $post = DB()->fetch_row("
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 : '',
@ -25,8 +54,7 @@ $data = array(
$sql_args = DB()->build_array('UPDATE', $data);
DB()->query("UPDATE " . BB_POSTS . " SET $sql_args WHERE post_id = $post_id");
if ($mc_type && $post['poster_id'] != $userdata['user_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);
@ -34,8 +62,7 @@ if ($mc_type && $post['poster_id'] != $userdata['user_id'])
cache_rm_user_sessions($post['poster_id']);
}
switch($mc_type)
{
switch ($mc_type) {
case 1: // Комментарий
$mc_class = 'success';
break;

View file

@ -1,15 +1,38 @@
<?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']))
{
if (!isset($this->request['type'])) {
$this->ajax_die('empty type');
}
if (isset($this->request['post_id']))
{
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
@ -18,42 +41,39 @@ if (isset($this->request['post_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'])
{
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) {
$this->ajax_die($lang['TOPIC_LOCKED']);
}
}
elseif (isset($this->request['topic_id']))
{
} 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);
}
if (!defined('WORD_LIST_OBTAINED'))
{
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'])
{
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']))
{
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);
@ -63,20 +83,15 @@ switch($this->request['type'])
$this->response['hide'] = true;
$this->response['post_id'] = $post_id;
}
else
{
} 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'))
{
if (bf($userdata['user_opt'], 'user_opt', 'dis_post')) {
$this->ajax_die(strip_tags($lang['RULES_REPLY_CANNOT']));
}
elseif(!$is_auth['auth_reply'])
{
} elseif (!$is_auth['auth_reply']) {
$this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type'])));
}
@ -88,17 +103,14 @@ switch($this->request['type'])
// hide sid
$message = preg_replace('#(?<=[\?&;]sid=)[a-zA-Z0-9]{12}#', 'sid', $message);
if (!empty($orig_word))
{
if (!empty($orig_word)) {
$message = (!empty($message)) ? preg_replace($orig_word, $replace_word, $message) : '';
}
if ($post['post_id'] == $post['topic_first_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)
{
if (mb_strlen($message, 'UTF-8') > 1000) {
$this->response['redirect'] = make_url(POSTING_URL . '?mode=quote&p=' . $post_id);
}
@ -108,7 +120,9 @@ switch($this->request['type'])
case 'view_message':
$message = (string)$this->request['message'];
if(!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']);
if (!trim($message)) {
$this->ajax_die($lang['EMPTY_MESSAGE']);
}
$message = htmlCHR($message, false, ENT_NOQUOTES);
$this->response['message_html'] = bbcode2html($message);
@ -117,38 +131,28 @@ switch($this->request['type'])
case 'edit':
case 'editor':
if (bf($userdata['user_opt'], 'user_opt', 'dis_post_edit'))
{
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'])
{
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))
{
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')
{
} 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'])
{
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'])
{
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'])
{
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);
@ -159,23 +163,19 @@ switch($this->request['type'])
'post_text' => $text,
));
}
} else {
$this->ajax_die($lang['EMPTY_MESSAGE']);
}
else $this->ajax_die($lang['EMPTY_MESSAGE']);
// Update atom feed
update_atom('topic', (int)$this->request['topic_id']);
$this->response['html'] = bbcode2html($text);
}
else
{
} else {
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])
{
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) {
$this->ajax_die($lang['TOPIC_LOCKED']);
}
elseif (!$is_auth['auth_edit'])
{
} elseif (!$is_auth['auth_edit']) {
$this->ajax_die(sprintf($lang['SORRY_AUTH_EDIT'], strip_tags($is_auth['auth_edit_type'])));
}
@ -228,21 +228,16 @@ switch($this->request['type'])
break;
case 'add':
if (!isset($this->request['topic_id']))
{
if (!isset($this->request['topic_id'])) {
$this->ajax_die('empty topic_id');
}
if (bf($userdata['user_opt'], 'user_opt', 'dis_post'))
{
if (bf($userdata['user_opt'], 'user_opt', 'dis_post')) {
$this->ajax_die(strip_tags($lang['RULES_REPLY_CANNOT']));
}
elseif (!$is_auth['auth_reply'])
{
} 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'])
{
if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) {
$this->ajax_die($lang['TOPIC_LOCKED']);
}
@ -253,20 +248,16 @@ switch($this->request['type'])
$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'])
{
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)
{
if (!empty($row['last_post_time']) && !IS_AM) {
$sql = "
SELECT pt.post_text
FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt
@ -276,22 +267,18 @@ switch($this->request['type'])
LIMIT 1
";
if ($row = DB()->fetch_row($sql))
{
if ($row = DB()->fetch_row($sql)) {
$last_msg = DB()->escape($row['post_text']);
if ($last_msg == $message)
{
if ($last_msg == $message) {
$this->ajax_die($lang['DOUBLE_POST_ERROR']);
}
}
}
if ($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'])
{
if ($count_smilies > $bb_cfg['max_smilies']) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
}
}
@ -310,8 +297,7 @@ switch($this->request['type'])
'post_text' => $message,
));
if ($bb_cfg['topic_notify_enabled'])
{
if ($bb_cfg['topic_notify_enabled']) {
$notify = !empty($this->request['notify']);
user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify);
}

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_AJAX')) die(basename(__FILE__));
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $lang;
@ -8,12 +33,10 @@ $mode = (string) $this->request['mode'];
$map = new sitemap();
$html = '';
switch ($mode)
{
switch ($mode) {
case 'create':
$map->create();
if (@file_exists(SITEMAP_DIR. 'sitemap.xml'))
{
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'];
@ -21,7 +44,9 @@ switch ($mode)
break;
case 'search_update':
if (!@file_exists(SITEMAP_DIR. 'sitemap.xml')) $map->create();
if (!@file_exists(SITEMAP_DIR . 'sitemap.xml')) {
$map->create();
}
$map_link = make_url(SITEMAP_DIR . 'sitemap.xml');

View file

@ -1,10 +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.
*/
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');
@ -12,42 +39,34 @@ $mode = (string) $this->request['mode'];
$sql_error = false;
// установка / начальная валидация значений
switch ($mode)
{
switch ($mode) {
case 'load':
case 'save':
if (!$tpl_id = (int) $this->request['tpl_id'])
{
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"))
{
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)
{
switch ($mode) {
case 'save':
case 'new':
if (!$tpl_name = htmlCHR(str_compact($this->request['tpl_name'])))
{
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']))
{
if (!$tpl_src_form = htmlCHR($this->request['tpl_src_form'])) {
$this->ajax_die('не заполнен скрипт формы шаблона');
}
if (!$tpl_src_title = htmlCHR($this->request['tpl_src_title']))
{
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']))
{
if (!$tpl_src_msg = htmlCHR($this->request['tpl_src_msg'])) {
$this->ajax_die('не заполнен формат создания сообщения');
}
@ -69,8 +88,7 @@ switch ($mode)
break;
}
// выполнение
switch ($mode)
{
switch ($mode) {
// загрузка шаблона
case 'load':
$this->response['val']['tpl-name-save'] = $tpl_data['tpl_name'];
@ -92,29 +110,22 @@ switch ($mode)
// включение / отключение шаблона в форуме
case 'assign':
if (!$tpl_id = (int) $this->request['tpl_id'])
{
if (!$tpl_id = (int)$this->request['tpl_id']) {
$this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)');
}
if (!$forum_id = (int) $this->request['forum_id'])
{
if (!$forum_id = (int)$this->request['forum_id']) {
$this->ajax_die('empty forum_id');
}
if (!forum_exists($forum_id))
{
if (!forum_exists($forum_id)) {
$this->ajax_die("нет такого форума [id: $forum_id]");
}
// отключение
if ($tpl_id == -1)
{
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'))
{
} // включение
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;
@ -125,16 +136,14 @@ switch ($mode)
// сохранение изменений
case 'save':
if ($tpl_data['tpl_last_edit_tm'] > $this->request['tpl_l_ed_tst'] && $tpl_data['tpl_last_edit_by'] != $userdata['user_id'])
{
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))
{
if (!@DB()->query($sql)) {
$sql_error = DB()->sql_error();
}
$this->response['tpl_id'] = $tpl_id;
@ -146,8 +155,7 @@ switch ($mode)
// создание нового шаблона
case 'new':
$sql = "INSERT INTO " . BB_TOPIC_TPL . DB()->build_array('INSERT', $sql_args);
if (!@DB()->query($sql))
{
if (!@DB()->query($sql)) {
$sql_error = DB()->sql_error();
}
break;
@ -158,10 +166,10 @@ switch ($mode)
}
// возможный дубль названия шаблона
if ($sql_error)
{
if ($sql_error['code'] == 1062) // Duplicate entry
{
if ($sql_error) {
if ($sql_error['code'] == 1062) {
// Duplicate entry
$this->ajax_die('Шаблон с таким названием уже существует, выберите другое название');
}
$this->ajax_die("db error {$sql_error['code']}: {$sql_error['message']}");

View file

@ -1,23 +1,44 @@
<?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'];
$html = '<img src="./styles/images/good.gif">';
switch($mode)
{
switch ($mode) {
case 'check_name':
$username = clean_username($this->request['username']);
if (empty($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))
{
} elseif ($err = validate_username($username)) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $err . '</span>';
}
break;
@ -25,12 +46,9 @@ switch($mode)
case 'check_email':
$email = (string)$this->request['email'];
if (empty($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))
{
} elseif ($err = validate_email($email)) {
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . $err . '</span>';
}
break;
@ -38,28 +56,17 @@ switch($mode)
case 'check_pass':
$pass = (string)$this->request['pass'];
$pass_confirm = (string)$this->request['pass_confirm'];
if (empty($pass) || empty($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)
{
} 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)
{
} 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)
{
} 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
{
} 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>';
}

View file

@ -1,14 +1,38 @@
<?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'];
if (!$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');
}
@ -26,24 +50,18 @@ $sql = "
LIMIT 1
";
if (!$post_data = DB()->fetch_row($sql))
{
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)
{
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)
{
} 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'])
{
if (!$is_auth['auth_read']) {
$this->ajax_die($lang['TOPIC_POST_NOT_EXIST']);
}
}

View file

@ -1,11 +1,35 @@
<?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']))
{
if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
$attach_id = (int)$this->request['attach_id'];
@ -14,17 +38,15 @@ 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']);
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)
{
if (($file_contents = @file_get_contents($filename)) === false) {
if (IS_AM) {
$this->ajax_die($lang['ERROR_NO_ATTACHMENT'] . "\n\n" . htmlCHR($filename));
}
else
{
} else {
$this->ajax_die($lang['ERROR_NO_ATTACHMENT']);
}
}
@ -36,8 +58,7 @@ function build_tor_filelist ($file_contents)
{
global $lang;
if (!$tor = bdecode($file_contents))
{
if (!$tor = bdecode($file_contents)) {
return $lang['TORFILE_INVALID'];
}
@ -63,18 +84,14 @@ class torrent
{
$this->build_filelist_array();
if ($this->multiple)
{
if ($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
{
} else {
return join('', $this->files_ary['/']);
}
}
@ -83,24 +100,19 @@ class torrent
{
$info = $this->tor_decoded['info'];
if (isset($info['name.utf-8']))
{
if (isset($info['name.utf-8'])) {
$info['name'] =& $info['name.utf-8'];
}
if (isset($info['files']) && is_array($info['files']))
{
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']))
{
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']))
{
if (!isset($f['path']) || !is_array($f['path'])) {
continue;
}
array_deep($f['path'], 'clean_tor_dirname');
@ -108,25 +120,20 @@ class torrent
$length = isset($f['length']) ? (float)$f['length'] : 0;
$subdir_count = count($f['path']) - 1;
if ($subdir_count > 0)
{
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++)
{
for ($i = 0, $j = 1; $i < $subdir_count; $i++, $j++) {
$subdir = $f['path'][$i];
if (!isset($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))
{
if ($j == $subdir_count) {
if (is_string($cur_files_ary)) {
$GLOBALS['bnc_error'] = 1;
break(1);
}
@ -134,17 +141,13 @@ class torrent
}
}
@natsort($cur_files_ary);
}
else
{
} else {
$name = $f['path'][0];
$this->files_ary['/'][] = $this->build_file_item($name, $length);
natsort($this->files_ary['/']);
}
}
}
else
{
} else {
$this->multiple = false;
$name = isset($info['name']) ? clean_tor_dirname($info['name']) : '';
$length = isset($info['length']) ? (float)$info['length'] : 0;
@ -160,8 +163,7 @@ class torrent
$magnet_name = $magnet_ext = '';
if ($bb_cfg['magnet_links_enabled'])
{
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>';
}
@ -181,6 +183,8 @@ function clean_tor_dirname ($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,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");
}
require(ATTACH_DIR . 'includes/functions_includes.php');
require(ATTACH_DIR . 'includes/functions_attach.php');
@ -8,8 +33,7 @@ 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'))
{
if (defined('ATTACH_INSTALL')) {
return;
}
@ -21,21 +45,15 @@ function attach_mod_get_lang($language_file)
global $attach_config, $bb_cfg;
$language = $bb_cfg['default_lang'];
if (!file_exists(LANG_ROOT_DIR ."$language/$language_file.php"))
{
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"))
{
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
{
} else {
return $language;
}
}
else
{
} else {
return $language;
}
}
@ -51,13 +69,11 @@ function get_config()
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachment information');
}
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$attach_config[$row['config_name']] = trim($row['config_value']);
}
@ -70,8 +86,7 @@ function get_config()
// Get Attachment Config
$attach_config = array();
if (!$attach_config = CACHE('bb_cache')->get('attach_config'))
{
if (!$attach_config = CACHE('bb_cache')->get('attach_config')) {
$attach_config = get_config();
CACHE('bb_cache')->set('attach_config', $attach_config, 86400);
}

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();
@ -15,15 +40,13 @@ function init_complete_extensions_data()
{
global $allowed_extensions, $display_categories, $download_modes, $upload_icons;
if (!$extension_informations = get_extension_informations())
{
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++)
{
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']);
@ -43,19 +66,16 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop
// 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 (!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]))
{
if (!isset($template->files[$template_var])) {
die("Template->loadfile(): No file specified for handle $template_var");
}
$filename_2 = $template->files[$template_var];
$str = implode('', @file($filename_2));
if (empty($str))
{
if (empty($str)) {
die("Template->loadfile(): File $filename_2 for handle $template_var is empty");
}
@ -63,19 +83,16 @@ function init_display_template($template_var, $replacement, $filename = 'viewtop
}
$complete_filename = $filename;
if (substr($complete_filename, 0, 1) != '/')
{
if (substr($complete_filename, 0, 1) != '/') {
$complete_filename = $template->root . '/' . $complete_filename;
}
if (!file_exists($complete_filename))
{
if (!file_exists($complete_filename)) {
die("Template->make_filename(): Error - file $complete_filename does not exist");
}
$content = implode('', file($complete_filename));
if (empty($content))
{
if (empty($content)) {
die('Template->loadfile(): File ' . $complete_filename . ' is empty');
}
@ -90,13 +107,11 @@ function display_post_attachments($post_id, $switch_attachment)
{
global $attach_config, $is_auth;
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']))
{
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod'])) {
return;
}
if ($is_auth['auth_download'] && $is_auth['auth_view'])
{
if ($is_auth['auth_download'] && $is_auth['auth_view']) {
display_attachments($post_id);
}
}
@ -108,51 +123,42 @@ function init_display_post_attachments($switch_attachment)
{
global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data;
if (empty($t_data) && !empty($forum_row))
{
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'])))
{
if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view']))) {
init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl');
return;
}
$post_id_array = array();
for ($i = 0; $i < $total_posts; $i++)
{
if ($postrow[$i]['post_attachment'] == 1)
{
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)
{
if (sizeof($post_id_array) == 0) {
return;
}
$rows = get_attachments_from_post($post_id_array);
$num_rows = sizeof($rows);
if ($num_rows == 0)
{
if ($num_rows == 0) {
return;
}
@reset($attachments);
for ($i = 0; $i < $num_rows; $i++)
{
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>');
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']);
}
@ -179,27 +185,22 @@ function display_attachments($post_id)
$num_attachments = @sizeof($attachments['_' . $post_id]);
if ($num_attachments == 0)
{
if ($num_attachments == 0) {
return;
}
$template->assign_block_vars('postrow.attach', array());
for ($i = 0; $i < $num_attachments; $i++)
{
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 = '';
if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']]))
{
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']]) != '')
{
} elseif (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '') {
$upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />';
}
@ -212,8 +213,7 @@ function display_attachments($post_id)
$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))
{
if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) {
$denied = true;
$template->assign_block_vars('postrow.attach.denyrow', array(
@ -221,60 +221,45 @@ function display_attachments($post_id)
);
}
if (!$denied || IS_ADMIN)
{
if (!$denied || IS_ADMIN) {
// define category
$image = FALSE;
$thumbnail = FALSE;
$link = FALSE;
$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)
{
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;
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;
} 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)
{
if ($image) {
// Images
if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
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
{
$download_link = true;
} else {
$img_source = $filename;
$download_link = FALSE;
$download_link = false;
}
$template->assign_block_vars('postrow.attach.cat_images', array(
@ -286,28 +271,22 @@ function display_attachments($post_id)
));
// Directly Viewed Image ... update the download count
if (!$download_link)
{
if (!$download_link) {
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . '
SET download_count = download_count + 1
WHERE attach_id = ' . (int)$attachments['_' . $post_id][$i]['attach_id'];
if (!(DB()->sql_query($sql)))
{
if (!(DB()->sql_query($sql))) {
bb_die('Could not update attachment download count');
}
}
}
if ($thumbnail)
{
if ($thumbnail) {
// Images, but display Thumbnail
if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
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
{
} else {
$thumb_source = $thumbnail_filename;
}
@ -322,12 +301,9 @@ function display_attachments($post_id)
}
// bt
if ($link && ($attachments['_'. $post_id][$i]['extension'] === TORRENT_EXT))
{
if ($link && ($attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT)) {
include(ATTACH_DIR . 'displaying_torrent.php');
}
else if ($link)
{
} elseif ($link) {
$target_blank = ((@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT)) ? 'target="_blank"' : '';
// display attachment

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(basename(__FILE__));
if (!defined('IN_FORUM')) {
die(basename(__FILE__));
}
global $bb_cfg, $t_data, $poster_id, $is_auth, $dl_link_css, $dl_status_css, $lang, $images;
@ -35,23 +60,16 @@ $get_sp_mode = (isset($_GET['spmode'])) ? $_GET['spmode'] : '';
$s_mode = 'count';
if ($cfg_sp_mode == SHOW_PEERS_NAMES)
{
if ($cfg_sp_mode == SHOW_PEERS_NAMES) {
$s_mode = 'names';
}
else if ($cfg_sp_mode == SHOW_PEERS_FULL)
{
} elseif ($cfg_sp_mode == SHOW_PEERS_FULL) {
$s_mode = 'full';
}
if ($bb_cfg['bt_allow_spmode_change'])
{
if ($get_sp_mode == 'names')
{
if ($bb_cfg['bt_allow_spmode_change']) {
if ($get_sp_mode == 'names') {
$s_mode = 'names';
}
else if ($get_sp_mode == 'full')
{
} elseif ($get_sp_mode == 'full') {
$s_mode = 'full';
}
}
@ -78,21 +96,18 @@ $tracker_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO'];
$download_link = DOWNLOAD_URL . $attach_id;
$description = ($comment) ? $comment : preg_replace("#.torrent$#i", '', $display_name);
if ($tor_auth_reg || $tor_auth_del)
{
if ($tor_auth_reg || $tor_auth_del) {
$reg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : ' . $attach_id . ', type: \'reg\'}); return false;">' . $lang['BT_REG_ON_TRACKER'] . '</a>';
$unreg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : ' . $attach_id . ', type: \'unreg\'}); return false;">' . $lang['BT_UNREG_FROM_TRACKER'] . '</a>';
$tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url;
}
if ($bb_cfg['torrent_name_style'])
{
if ($bb_cfg['torrent_name_style']) {
$display_name = '[' . $bb_cfg['server_name'] . '].t' . $bt_topic_id . '.torrent';
}
if (!$tor_reged)
{
if (!$tor_reged) {
$template->assign_block_vars('postrow.attach.tor_not_reged', array(
'DOWNLOAD_NAME' => $display_name,
'TRACKER_LINK' => $tracker_link,
@ -106,48 +121,40 @@ if (!$tor_reged)
'POSTED_TIME' => $tor_file_time,
));
if ($comment)
{
if ($comment) {
$template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment));
}
}
else
{
} else {
$sql = "SELECT bt.*, u.user_id, u.username, u.user_rank
FROM " . BB_BT_TORRENTS . " bt
LEFT JOIN " . BB_USERS . " u ON(bt.checked_user_id = u.user_id)
WHERE bt.attach_id = $attach_id";
if (!$result = DB()->sql_query($sql))
{
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain torrent information');
}
$tor_info = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result);
}
if ($tor_reged && !$tor_info)
{
if ($tor_reged && !$tor_info) {
DB()->query("UPDATE " . BB_ATTACHMENTS_DESC . " SET tracker_status = 0 WHERE attach_id = $attach_id");
bb_die('Torrent status fixed');
}
if ($tor_auth)
{
if ($tor_auth) {
$template->assign_vars(array(
'TOR_CONTROLS' => true,
'TOR_ATTACH_ID' => $attach_id,
));
if ($t_data['self_moderated'] || $is_auth['auth_mod'])
{
if ($t_data['self_moderated'] || $is_auth['auth_mod']) {
$template->assign_vars(array('AUTH_MOVE' => true));
}
}
if ($tor_reged && $tor_info)
{
if ($tor_reged && $tor_info) {
$tor_size = ($tor_info['size']) ? $tor_info['size'] : 0;
$tor_id = $tor_info['topic_id'];
$tor_type = $tor_info['tor_type'];
@ -162,16 +169,13 @@ if ($tor_reged && $tor_info)
$dl_allowed = true;
$user_ratio = 0;
if (($min_ratio_dl || $min_ratio_warn) && $bt_user_id != $poster_id)
{
if (($min_ratio_dl || $min_ratio_warn) && $bt_user_id != $poster_id) {
$sql = "SELECT u.*, dl.user_status
FROM " . BB_BT_USERS . " u
LEFT JOIN " . BB_BT_DLSTATUS . " dl ON dl.user_id = $bt_user_id AND dl.topic_id = $bt_topic_id
WHERE u.user_id = $bt_user_id
LIMIT 1";
}
else
{
} else {
$sql = "SELECT user_status
FROM " . BB_BT_DLSTATUS . "
WHERE user_id = $bt_user_id
@ -183,15 +187,12 @@ if ($tor_reged && $tor_info)
$user_status = isset($bt_userdata['user_status']) ? $bt_userdata['user_status'] : null;
if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD)
{
if (($user_ratio = get_bt_ratio($bt_userdata)) !== null)
{
if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD) {
if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) {
$dl_allowed = ($user_ratio > $min_ratio_dl);
}
if ((isset($user_ratio) && isset($min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO))
{
if ((isset($user_ratio) && isset($min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) {
$template->assign_vars(array(
'SHOW_RATIO_WARN' => true,
'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']),
@ -199,16 +200,13 @@ if ($tor_reged && $tor_info)
}
}
if (!$dl_allowed)
{
if (!$dl_allowed) {
$template->assign_block_vars('postrow.attach.tor_reged', array());
$template->assign_vars(array(
'TOR_BLOCKED' => true,
'TOR_BLOCKED_MSG' => sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu=$bt_user_id&amp;dlc=1"),
));
}
else
{
} else {
$template->assign_block_vars('postrow.attach.tor_reged', array(
'DOWNLOAD_NAME' => $display_name,
'TRACKER_LINK' => $tracker_link,
@ -238,14 +236,12 @@ if ($tor_reged && $tor_info)
'COMPLETED' => sprintf($lang['DOWNLOAD_NUMBER'], $tor_info['complete_count']),
));
if ($comment)
{
if ($comment) {
$template->assign_block_vars('postrow.attach.tor_reged.comment', array('COMMENT' => $comment));
}
}
if ($bb_cfg['show_tor_info_in_dl_list'])
{
if ($bb_cfg['show_tor_info_in_dl_list']) {
$template->assign_vars(array(
'SHOW_DL_LIST' => true,
'SHOW_DL_LIST_TOR_INFO' => true,
@ -257,25 +253,19 @@ if ($tor_reged && $tor_info)
}
// Show peers
if ($show_peers)
{
if ($show_peers) {
// Sorting order in full mode
if ($s_mode == 'full')
{
if ($s_mode == 'full') {
$full_mode_order = 'tr.remain';
$full_mode_sort_dir = 'ASC';
if (isset($_REQUEST['psortasc']))
{
if (isset($_REQUEST['psortasc'])) {
$full_mode_sort_dir = 'ASC';
}
else if (isset($_REQUEST['psortdesc']))
{
} elseif (isset($_REQUEST['psortdesc'])) {
$full_mode_sort_dir = 'DESC';
}
if (isset($_REQUEST['porder']))
{
if (isset($_REQUEST['porder'])) {
$peer_orders = array(
'name' => 'u.username',
'ip' => 'tr.ip',
@ -288,10 +278,8 @@ if ($tor_reged && $tor_info)
'time' => 'tr.update_time',
);
foreach ($peer_orders as $get_key => $order_by_value)
{
if ($_REQUEST['porder'] == $get_key)
{
foreach ($peer_orders as $get_key => $order_by_value) {
if ($_REQUEST['porder'] == $get_key) {
$full_mode_order = $order_by_value;
break;
}
@ -299,15 +287,12 @@ if ($tor_reged && $tor_info)
}
}
// SQL for each mode
if ($s_mode == 'count')
{
if ($s_mode == 'count') {
$sql = "SELECT seeders, leechers, speed_up, speed_down
FROM " . BB_BT_TRACKER_SNAP . "
WHERE topic_id = $tor_id
LIMIT 1";
}
else if ($s_mode == 'names')
{
} elseif ($s_mode == 'names') {
$sql = "SELECT tr.user_id, tr.ip, tr.port, tr.remain, tr.seeder, u.username, u.user_rank
FROM " . BB_BT_TRACKER . " tr, " . BB_USERS . " u
WHERE tr.topic_id = $tor_id
@ -315,9 +300,7 @@ if ($tor_reged && $tor_info)
GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder
ORDER BY u.username
LIMIT $show_peers_limit";
}
else
{
} else {
$sql = "SELECT
tr.user_id, tr.ip, tr.port, tr.uploaded, tr.downloaded, tr.remain,
tr.seeder, tr.releaser, tr.speed_up, tr.speed_down, tr.update_time,
@ -331,8 +314,7 @@ if ($tor_reged && $tor_info)
}
// Build peers table
if ($peers = DB()->fetch_rowset($sql))
{
if ($peers = DB()->fetch_rowset($sql)) {
$peers_cnt = count($peers);
$cnt = $tr = $sp_up = $sp_down = $sp_up_tot = $sp_down_tot = array();
@ -345,10 +327,8 @@ if ($tor_reged && $tor_info)
$max_up_id['s'] = $max_down_id['s'] = $max_sp_up_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1);
$max_up_id['l'] = $max_down_id['l'] = $max_sp_up_id['l'] = $max_sp_down_id['l'] = ($peers_cnt + 1);
if ($s_mode == 'full')
{
foreach ($peers as $pid => $peer)
{
if ($s_mode == 'full') {
foreach ($peers as $pid => $peer) {
$x = ($peer['seeder']) ? 's' : 'l';
$cnt[$x]++;
$sp_up_tot[$x] += $peer['speed_up'];
@ -358,41 +338,34 @@ if ($tor_reged && $tor_info)
$p_max_up = $peer['uploaded'];
$p_max_down = $peer['downloaded'];
if ($p_max_up > $max_up[$x])
{
if ($p_max_up > $max_up[$x]) {
$max_up[$x] = $p_max_up;
$max_up_id[$x] = $pid;
}
if ($peer['speed_up'] > $max_sp_up[$x])
{
if ($peer['speed_up'] > $max_sp_up[$x]) {
$max_sp_up[$x] = $peer['speed_up'];
$max_sp_up_id[$x] = $pid;
}
if ($p_max_down > $max_down[$x])
{
if ($p_max_down > $max_down[$x]) {
$max_down[$x] = $p_max_down;
$max_down_id[$x] = $pid;
}
if ($peer['speed_down'] > $max_sp_down[$x])
{
if ($peer['speed_down'] > $max_sp_down[$x]) {
$max_sp_down[$x] = $peer['speed_down'];
$max_sp_down_id[$x] = $pid;
}
}
$max_down_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1);
if ($cnt['s'] == 1)
{
if ($cnt['s'] == 1) {
$max_up_id['s'] = $max_sp_up_id['s'] = ($peers_cnt + 1);
}
if ($cnt['l'] == 1)
{
if ($cnt['l'] == 1) {
$max_up_id['l'] = $max_down_id['l'] = $max_sp_up_id['l'] = $max_sp_down_id['l'] = ($peers_cnt + 1);
}
}
if ($s_mode == 'count')
{
if ($s_mode == 'count') {
$tmp = array();
$tmp[0]['seeder'] = $tmp[0]['username'] = $tmp[1]['username'] = 0;
$tmp[1]['seeder'] = 1;
@ -408,13 +381,11 @@ if ($tor_reged && $tor_info)
));
}
foreach ($peers as $pid => $peer)
{
foreach ($peers as $pid => $peer) {
$u_prof_href = ($s_mode == 'count') ? '#' : "profile.php?mode=viewprofile&amp;u=" . $peer['user_id'] . "#torrent";
// Full details mode
if ($s_mode == 'full')
{
if ($s_mode == 'full') {
$ip = bt_show_ip($peer['ip']);
$port = bt_show_port($peer['port']);
@ -424,14 +395,12 @@ if ($tor_reged && $tor_info)
$p_cur_up = $peer['uploaded'];
$p_cur_down = $peer['downloaded'];
if ($peer['seeder'])
{
if ($peer['seeder']) {
$x = 's';
$x_row = 'srow';
$x_full = 'sfull';
if (!defined('SEEDER_EXIST'))
{
if (!defined('SEEDER_EXIST')) {
define('SEEDER_EXIST', true);
$seed_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#seeders";
@ -440,25 +409,20 @@ if ($tor_reged && $tor_info)
'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s'
));
if ($ip)
{
if ($ip) {
$template->assign_block_vars("$x_full.iphead", array());
}
if ($port !== false)
{
if ($port !== false) {
$template->assign_block_vars("$x_full.porthead", array());
}
}
$compl_perc = ($tor_size) ? round(($p_max_up / $tor_size), 1) : 0;
}
else
{
} else {
$x = 'l';
$x_row = 'lrow';
$x_full = 'lfull';
if (!defined('LEECHER_EXIST'))
{
if (!defined('LEECHER_EXIST')) {
define('LEECHER_EXIST', true);
$leech_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#leechers";
@ -468,12 +432,10 @@ if ($tor_reged && $tor_info)
'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') . '/s'
));
if ($ip)
{
if ($ip) {
$template->assign_block_vars("$x_full.iphead", array());
}
if ($port !== false)
{
if ($port !== false) {
$template->assign_block_vars("$x_full.porthead", array());
}
}
@ -509,25 +471,18 @@ if ($tor_reged && $tor_info)
'TOR_RATIO' => ($up_ratio) ? $lang['USER_RATIO'] . "UL/DL: $up_ratio" : '',
));
if ($ip)
{
if ($ip) {
$template->assign_block_vars("$x_full.$x_row.ip", array('IP' => $ip));
}
if ($port !== false)
{
if ($port !== false) {
$template->assign_block_vars("$x_full.$x_row.port", array('PORT' => $port));
}
}
// Count only & only names modes
else
{
if ($peer['seeder'])
{
} // Count only & only names modes
else {
if ($peer['seeder']) {
$seeders .= '<nobr><a href="' . $u_prof_href . '" class="seedmed">' . $peer['username'] . '</a>,</nobr> ';
$seed_count = $peer['username'];
}
else
{
} else {
$compl_size = (@$peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0;
$compl_perc = ($compl_size) ? floor($compl_size * 100 / $tor_size) : 0;
@ -539,16 +494,14 @@ if ($tor_reged && $tor_info)
}
}
if ($s_mode != 'full' && $seeders)
{
if ($s_mode != 'full' && $seeders) {
$seeders[strlen($seeders) - 9] = ' ';
$template->assign_vars(array(
'SEED_LIST' => $seeders,
'SEED_COUNT' => ($seed_count) ? $seed_count : 0,
));
}
if ($s_mode != 'full' && $leechers)
{
if ($s_mode != 'full' && $leechers) {
$leechers[strlen($leechers) - 9] = ' ';
$template->assign_vars(array(
'LEECH_LIST' => $leechers,
@ -559,8 +512,7 @@ if ($tor_reged && $tor_info)
unset($peers);
// Show "seeder last seen info"
if (($s_mode == 'count' && !$seed_count) || (!$seeders && !defined('SEEDER_EXIST')))
{
if (($s_mode == 'count' && !$seed_count) || (!$seeders && !defined('SEEDER_EXIST'))) {
$last_seen_time = ($tor_info['seeder_last_seen']) ? delta_time($tor_info['seeder_last_seen']) : $lang['NEVER'];
$template->assign_vars(array(
@ -571,19 +523,15 @@ if ($tor_reged && $tor_info)
$template->assign_block_vars('tor_title', array('U_DOWNLOAD_LINK' => $download_link));
if ($peers_cnt > $max_peers_before_overflow && $s_mode == 'full')
{
if ($peers_cnt > $max_peers_before_overflow && $s_mode == 'full') {
$template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_overflow));
$template->assign_vars(array('PEERS_OVERFLOW' => true));
}
else
{
} else {
$template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_normal));
}
}
if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full')
{
if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full') {
$template->assign_vars(array(
'PEERS_FULL_LINK' => true,
'SPMODE_FULL_HREF' => "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#seeders",

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.
*/
/**
* All Attachment Functions only needed in Admin
@ -13,29 +36,23 @@ function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
$quota_type = (int)$quota_type;
$quota_limit_id = (int)$quota_limit_id;
if ($mode == 'user')
{
if (!$quota_limit_id)
{
if ($mode == 'user') {
if (!$quota_limit_id) {
$sql = 'DELETE FROM ' . BB_QUOTA . "
WHERE user_id = $id
AND quota_type = $quota_type";
}
else
{
} 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)) )
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get entry #1');
}
if (DB()->num_rows($result) == 0)
{
if (DB()->num_rows($result) == 0) {
$sql_ary = array(
'user_id' => (int)$id,
'group_id' => 0,
@ -44,9 +61,7 @@ function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
);
$sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
}
else
{
} else {
$sql = 'UPDATE ' . BB_QUOTA . "
SET quota_limit_id = $quota_limit_id
WHERE user_id = $id
@ -55,51 +70,38 @@ function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
DB()->sql_freeresult($result);
}
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to update quota settings');
}
}
else if ($mode == 'group')
{
if (!$quota_limit_id)
{
} 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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to delete quota settings');
}
}
else
{
} 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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get entry #2');
}
if (DB()->num_rows($result) == 0)
{
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
{
} 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))
{
if (!DB()->sql_query($sql)) {
bb_die('Unable to update quota settings');
}
}
@ -113,42 +115,31 @@ function sort_multi_array ($sort_array, $key, $sort_order, $pre_string_sort = 0)
{
$last_element = sizeof($sort_array) - 1;
if (!$pre_string_sort)
{
if (!$pre_string_sort) {
$string_sort = (!is_numeric(@$sort_array[$last_element - 1][$key])) ? true : false;
}
else
{
} else {
$string_sort = $pre_string_sort;
}
for ($i = 0; $i < $last_element; $i++)
{
for ($i = 0; $i < $last_element; $i++) {
$num_iterations = $last_element - $i;
for ($j = 0; $j < $num_iterations; $j++)
{
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])))
{
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))
{
} 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)
{
if ($switch) {
$temp = $sort_array[$j];
$sort_array[$j] = $sort_array[$j + 1];
$sort_array[$j + 1] = $temp;
@ -168,19 +159,14 @@ function get_formatted_dirsize()
$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))
{
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
{
} else {
$upload_dir_size = $lang['NOT_AVAILABLE'];
return $upload_dir_size;
}
@ -200,14 +186,12 @@ function search_attachments($order_by, &$total_rows)
// 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++)
{
for ($i = 0; $i < sizeof($search_vars); $i++) {
$$search_vars[$i] = get_var($search_vars[$i], '');
}
// Author name search
if ($search_author != '')
{
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));
@ -218,24 +202,18 @@ function search_attachments($order_by, &$total_rows)
// 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)))
{
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
{
if ($row = DB()->sql_fetchrow($result)) {
do {
$matching_userids .= (($matching_userids != '') ? ', ' : '') . intval($row['user_id']);
}
while ($row = DB()->sql_fetchrow($result));
} while ($row = DB()->sql_fetchrow($result));
DB()->sql_freeresult($result);
}
else
{
} else {
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
}
@ -243,53 +221,41 @@ function search_attachments($order_by, &$total_rows)
}
// Search Keyword
if ($search_keyword_fname != '')
{
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 != '')
{
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 != '')
{
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 != '')
{
} 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 != '')
{
if ($search_size_smaller != '' || $search_size_greater != '') {
if ($search_size_smaller != '') {
$where_sql[] = ' (a.filesize < ' . (int)$search_size_smaller . ') ';
}
else if ($search_size_greater != '')
{
} elseif ($search_size_greater != '') {
$where_sql[] = ' (a.filesize > ' . (int)$search_size_greater . ') ';
}
}
// Search Attachment Time
if ($search_days_greater != '')
{
if ($search_days_greater != '') {
$where_sql[] = ' (a.filetime < ' . (TIMENOW - ((int)$search_days_greater * 86400)) . ') ';
}
// Search Forum
if ($search_forum)
{
if ($search_forum) {
$where_sql[] = ' (p.forum_id = ' . intval($search_forum) . ') ';
}
@ -298,8 +264,7 @@ function search_attachments($order_by, &$total_rows)
$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)
{
if (sizeof($where_sql) > 0) {
$sql .= implode('AND', $where_sql) . ' AND ';
}
@ -309,8 +274,7 @@ function search_attachments($order_by, &$total_rows)
$sql .= $order_by;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attachments #1');
}
@ -318,13 +282,11 @@ function search_attachments($order_by, &$total_rows)
$num_attach = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_attach == 0)
{
if ($num_attach == 0) {
bb_die($lang['NO_ATTACH_SEARCH_MATCH']);
}
if (!($result = DB()->sql_query($total_rows_sql)))
{
if (!($result = DB()->sql_query($total_rows_sql))) {
bb_die('Could not query attachments #2');
}
@ -344,8 +306,7 @@ function limit_array($array, $start, $pagelimit)
$limit_array = array();
for ($i = $start; $i < $limit; $i++)
{
for ($i = $start; $i < $limit; $i++) {
$limit_array[] = $array[$i];
}

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.
*/
/**
* All Attachment Functions needed everywhere
@ -7,8 +30,7 @@
/**
* html_entity_decode replacement (from php manual)
*/
if (!function_exists('html_entity_decode'))
{
if (!function_exists('html_entity_decode')) {
function html_entity_decode($given_html, $quote_style = ENT_QUOTES)
{
$trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style));
@ -25,23 +47,18 @@ function base64_pack($number)
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-';
$base = strlen($chars);
if ($number > 4096)
{
if ($number > 4096) {
return;
}
else if ($number < $base)
{
} elseif ($number < $base) {
return $chars[$number];
}
$hexval = '';
while ($number > 0)
{
while ($number > 0) {
$remainder = $number % $base;
if ($remainder < $base)
{
if ($remainder < $base) {
$hexval = $chars[$remainder] . $hexval;
}
@ -62,8 +79,7 @@ function base64_unpack($string)
$length = strlen($string);
$number = 0;
for($i = 1; $i <= $length; $i++)
{
for ($i = 1; $i <= $length; $i++) {
$pos = $length - $i;
$operand = strpos($chars, substr($string, $pos, 1));
$exponent = pow($base, $i - 1);
@ -85,16 +101,12 @@ function auth_pack($auth_array)
$one_char = $two_char = false;
$auth_cache = '';
for ($i = 0; $i < sizeof($auth_array); $i++)
{
for ($i = 0; $i < sizeof($auth_array); $i++) {
$val = base64_pack(intval($auth_array[$i]));
if (strlen($val) == 1 && !$one_char)
{
if (strlen($val) == 1 && !$one_char) {
$auth_cache .= $one_char_encoding;
$one_char = true;
}
else if (strlen($val) == 2 && !$two_char)
{
} elseif (strlen($val) == 2 && !$two_char) {
$auth_cache .= $two_char_encoding;
$two_char = true;
}
@ -116,16 +128,12 @@ function auth_unpack($auth_cache)
$auth = array();
$auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len)
{
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) {
$forum_auth = substr($auth_cache, $pos, 1);
if ($forum_auth == $one_char_encoding)
{
if ($forum_auth == $one_char_encoding) {
$auth_len = 1;
continue;
}
else if ($forum_auth == $two_char_encoding)
{
} elseif ($forum_auth == $two_char_encoding) {
$auth_len = 2;
$pos--;
continue;
@ -146,24 +154,19 @@ function is_forum_authed($auth_cache, $check_forum_id)
$one_char_encoding = '#';
$two_char_encoding = '.';
if (trim($auth_cache) == '')
{
if (trim($auth_cache) == '') {
return true;
}
$auth = array();
$auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos+=$auth_len)
{
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) {
$forum_auth = substr($auth_cache, $pos, 1);
if ($forum_auth == $one_char_encoding)
{
if ($forum_auth == $one_char_encoding) {
$auth_len = 1;
continue;
}
else if ($forum_auth == $two_char_encoding)
{
} elseif ($forum_auth == $two_char_encoding) {
$auth_len = 2;
$pos--;
continue;
@ -171,8 +174,7 @@ function is_forum_authed($auth_cache, $check_forum_id)
$forum_auth = substr($auth_cache, $pos, $auth_len);
$forum_id = (int)base64_unpack($forum_auth);
if ($forum_id == $check_forum_id)
{
if ($forum_id == $check_forum_id) {
return true;
}
}
@ -188,12 +190,9 @@ function unlink_attach($filename, $mode = false)
$filename = basename($filename);
if ($mode == MODE_THUMBNAIL)
{
if ($mode == MODE_THUMBNAIL) {
$filename = $upload_dir . '/' . THUMB_DIR . '/t_' . $filename;
}
else
{
} else {
$filename = $upload_dir . '/' . $filename;
}
@ -211,12 +210,9 @@ function attachment_exists($filename)
$filename = basename($filename);
if (!@file_exists(@amod_realpath($upload_dir . '/' . $filename)))
{
if (!@file_exists(@amod_realpath($upload_dir . '/' . $filename))) {
return false;
}
else
{
} else {
return true;
}
}
@ -230,12 +226,9 @@ function thumbnail_exists($filename)
$filename = basename($filename);
if (!@file_exists(@amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename)))
{
if (!@file_exists(@amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename))) {
return false;
}
else
{
} else {
return true;
}
}
@ -245,8 +238,7 @@ function thumbnail_exists($filename)
*/
function physical_filename_already_stored($filename)
{
if ($filename == '')
{
if ($filename == '') {
return false;
}
@ -257,8 +249,7 @@ function physical_filename_already_stored($filename)
WHERE physical_filename = '" . attach_mod_sql_escape($filename) . "'
LIMIT 1";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get attachment information for filename: ' . htmlspecialchars($filename));
}
$num_rows = DB()->num_rows($result);
@ -276,10 +267,8 @@ function get_attachments_from_post($post_id_array)
$attachments = array();
if (!is_array($post_id_array))
{
if (empty($post_id_array))
{
if (!is_array($post_id_array)) {
if (empty($post_id_array)) {
return $attachments;
}
@ -291,8 +280,7 @@ function get_attachments_from_post($post_id_array)
$post_id_array = implode(', ', array_map('intval', $post_id_array));
if ($post_id_array == '')
{
if ($post_id_array == '') {
return $attachments;
}
@ -304,8 +292,7 @@ function get_attachments_from_post($post_id_array)
AND a.attach_id = d.attach_id
ORDER BY d.filetime $display_order";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get attachment informations for post number ' . $post_id_array);
}
@ -313,8 +300,7 @@ function get_attachments_from_post($post_id_array)
$attachments = DB()->sql_fetchrowset($result);
DB()->sql_freeresult($result);
if ($num_rows == 0)
{
if ($num_rows == 0) {
return array();
}
@ -326,29 +312,25 @@ function get_attachments_from_post($post_id_array)
*/
function get_total_attach_filesize($attach_ids)
{
if (!is_array($attach_ids) || !sizeof($attach_ids))
{
if (!is_array($attach_ids) || !sizeof($attach_ids)) {
return 0;
}
$attach_ids = implode(', ', array_map('intval', $attach_ids));
if (!$attach_ids)
{
if (!$attach_ids) {
return 0;
}
$sql = 'SELECT filesize FROM ' . BB_ATTACHMENTS_DESC . " WHERE attach_id IN ($attach_ids)";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query total filesize');
}
$total_filesize = 0;
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$total_filesize += (int)$row['filesize'];
}
DB()->sql_freeresult($result);
@ -369,8 +351,7 @@ function get_extension_informations()
//
function attachment_sync_topic($topics)
{
if (is_array($topics))
{
if (is_array($topics)) {
$topics = join(',', $topics);
}
$posts_without_attach = $topics_without_attach = array();
@ -383,14 +364,11 @@ function attachment_sync_topic ($topics)
AND p.post_attachment = 1
AND a.post_id IS NULL";
if ($rowset = DB()->fetch_rowset($sql))
{
foreach ($rowset as $row)
{
if ($rowset = DB()->fetch_rowset($sql)) {
foreach ($rowset as $row) {
$posts_without_attach[] = $row['post_id'];
}
if ($posts_sql = join(',', $posts_without_attach))
{
if ($posts_sql = join(',', $posts_without_attach)) {
DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
}
}
@ -413,14 +391,11 @@ function attachment_sync_topic ($topics)
GROUP BY p.topic_id
HAVING SUM(p.post_attachment) = 0";
if ($rowset = DB()->fetch_rowset($sql))
{
foreach ($rowset as $row)
{
if ($rowset = DB()->fetch_rowset($sql)) {
foreach ($rowset as $row) {
$topics_without_attach[] = $row['topic_id'];
}
if ($topics_sql = join(',', $topics_without_attach))
{
if ($topics_sql = join(',', $topics_without_attach)) {
DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
}
}
@ -431,19 +406,15 @@ function attachment_sync_topic ($topics)
*/
function get_extension($filename)
{
if (!stristr($filename, '.'))
{
if (!stristr($filename, '.')) {
return '';
}
$extension = strrchr(strtolower($filename), '.');
$extension[0] = ' ';
$extension = strtolower(trim($extension));
if (is_array($extension))
{
if (is_array($extension)) {
return '';
}
else
{
} else {
return $extension;
}
}
@ -464,8 +435,7 @@ function user_in_group($user_id, $group_id)
$user_id = (int)$user_id;
$group_id = (int)$group_id;
if (!$user_id || !$group_id)
{
if (!$user_id || !$group_id) {
return false;
}
@ -477,16 +447,14 @@ function user_in_group($user_id, $group_id)
AND g.group_id = $group_id
LIMIT 1";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get user group');
}
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows == 0)
{
if ($num_rows == 0) {
return false;
}
@ -513,13 +481,11 @@ function _set_var(&$result, $var, $type, $multibyte = false)
settype($var, $type);
$result = $var;
if ($type == 'string')
{
if ($type == 'string') {
$result = trim(str_replace(array("\r\n", "\r", '\xFF'), array("\n", "\n", ' '), $result));
// 2.0.x is doing addslashes on all variables
$result = stripslashes($result);
if ($multibyte)
{
if ($multibyte) {
$result = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $result);
}
}
@ -534,49 +500,37 @@ function get_var($var_name, $default, $multibyte = false)
{
$request_var = (isset($_POST[$var_name])) ? $_POST : $_GET;
if (!isset($request_var[$var_name]) || (is_array($request_var[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($request_var[$var_name])))
{
if (!isset($request_var[$var_name]) || (is_array($request_var[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($request_var[$var_name]))) {
return (is_array($default)) ? array() : $default;
}
$var = $request_var[$var_name];
if (!is_array($default))
{
if (!is_array($default)) {
$type = gettype($default);
}
else
{
} else {
list($key_type, $type) = each($default);
$type = gettype($type);
$key_type = gettype($key_type);
}
if (is_array($var))
{
if (is_array($var)) {
$_var = $var;
$var = array();
foreach ($_var as $k => $v)
{
if (is_array($v))
{
foreach ($v as $_k => $_v)
{
foreach ($_var as $k => $v) {
if (is_array($v)) {
foreach ($v as $_k => $_v) {
_set_var($k, $k, $key_type);
_set_var($_k, $_k, $key_type);
_set_var($var[$k][$_k], $_v, $type, $multibyte);
}
}
else
{
} else {
_set_var($k, $k, $key_type);
_set_var($var[$k], $v, $type, $multibyte);
}
}
}
else
{
} else {
_set_var($var, $var, $type, $multibyte);
}
@ -588,12 +542,9 @@ function get_var($var_name, $default, $multibyte = false)
*/
function attach_mod_sql_escape($text)
{
if (function_exists('mysqli_real_escape_string'))
{
if (function_exists('mysqli_real_escape_string')) {
return DB()->escape_string($text);
}
else
{
} else {
return str_replace("'", "''", str_replace('\\', '\\\\', $text));
}
}
@ -606,57 +557,38 @@ function attach_mod_sql_escape($text)
*/
function attach_mod_sql_build_array($query, $assoc_ary = false)
{
if (!is_array($assoc_ary))
{
if (!is_array($assoc_ary)) {
return false;
}
$fields = array();
$values = array();
if ($query == 'INSERT' || $query == 'INSERT_SELECT')
{
foreach ($assoc_ary as $key => $var)
{
if ($query == 'INSERT' || $query == 'INSERT_SELECT') {
foreach ($assoc_ary as $key => $var) {
$fields[] = $key;
if (is_null($var))
{
if (is_null($var)) {
$values[] = 'NULL';
}
else if (is_string($var))
{
} elseif (is_string($var)) {
$values[] = "'" . attach_mod_sql_escape($var) . "'";
}
else if (is_array($var) && is_string($var[0]))
{
} elseif (is_array($var) && is_string($var[0])) {
$values[] = $var[0];
}
else
{
} else {
$values[] = (is_bool($var)) ? intval($var) : $var;
}
}
$query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' ';
}
else if ($query == 'MULTI_INSERT')
{
} elseif ($query == 'MULTI_INSERT') {
$ary = array();
foreach ($assoc_ary as $id => $sql_ary)
{
foreach ($assoc_ary as $id => $sql_ary) {
$values = array();
foreach ($sql_ary as $key => $var)
{
if (is_null($var))
{
foreach ($sql_ary as $key => $var) {
if (is_null($var)) {
$values[] = 'NULL';
}
elseif (is_string($var))
{
} elseif (is_string($var)) {
$values[] = "'" . attach_mod_sql_escape($var) . "'";
}
else
{
} else {
$values[] = (is_bool($var)) ? intval($var) : $var;
}
}
@ -664,22 +596,14 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
}
$query = ' (' . implode(', ', array_keys($assoc_ary[0])) . ') VALUES ' . implode(', ', $ary);
}
else if ($query == 'UPDATE' || $query == 'SELECT')
{
} elseif ($query == 'UPDATE' || $query == 'SELECT') {
$values = array();
foreach ($assoc_ary as $key => $var)
{
if (is_null($var))
{
foreach ($assoc_ary as $key => $var) {
if (is_null($var)) {
$values[] = "$key = NULL";
}
elseif (is_string($var))
{
} elseif (is_string($var)) {
$values[] = "$key = '" . attach_mod_sql_escape($var) . "'";
}
else
{
} else {
$values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
}
}

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.
*/
/**
* All Attachment Functions processing the Deletion Process
@ -12,27 +35,19 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
global $bb_cfg;
// Generate Array, if it's not an array
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0)
{
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) {
return;
}
if ($post_id_array === 0 && $attach_id_array !== 0)
{
if ($post_id_array === 0 && $attach_id_array !== 0) {
$post_id_array = array();
if (!is_array($attach_id_array))
{
if (strstr($attach_id_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, ','))
{
} elseif (strstr($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
}
else
{
} else {
$attach_id = intval($attach_id_array);
$attach_id_array = array();
$attach_id_array[] = $attach_id;
@ -47,43 +62,33 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")
GROUP BY $p_id";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select ids');
}
$num_post_list = DB()->num_rows($result);
if ($num_post_list == 0)
{
if ($num_post_list == 0) {
DB()->sql_freeresult($result);
return;
}
while ($row = DB()->sql_fetchrow($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) == '')
{
if (!is_array($post_id_array)) {
if (trim($post_id_array) == '') {
return;
}
if (strstr($post_id_array, ', '))
{
if (strstr($post_id_array, ', ')) {
$post_id_array = explode(', ', $post_id_array);
}
else if (strstr($post_id_array, ','))
{
} elseif (strstr($post_id_array, ',')) {
$post_id_array = explode(',', $post_id_array);
}
else
{
} else {
$post_id = intval($post_id_array);
$post_id_array = array();
@ -91,14 +96,12 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
}
if (!sizeof($post_id_array))
{
if (!sizeof($post_id_array)) {
return;
}
// First of all, determine the post id and attach_id
if ($attach_id_array === 0)
{
if ($attach_id_array === 0) {
$attach_id_array = array();
// Get the attach_ids to fill the array
@ -108,38 +111,29 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
FROM ' . BB_ATTACHMENTS . " $whereclause
GROUP BY attach_id";
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select attachment id #1');
}
$num_attach_list = DB()->num_rows($result);
if ($num_attach_list == 0)
{
if ($num_attach_list == 0) {
DB()->sql_freeresult($result);
return;
}
while ($row = DB()->sql_fetchrow($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, ', '))
{
if (!is_array($attach_id_array)) {
if (strstr($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array);
}
else if (strstr($attach_id_array, ','))
{
} elseif (strstr($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
}
else
{
} else {
$attach_id = intval($attach_id_array);
$attach_id_array = array();
@ -147,49 +141,41 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
}
if (!sizeof($attach_id_array))
{
if (!sizeof($attach_id_array)) {
return;
}
$sql_id = 'post_id';
if (sizeof($post_id_array) && sizeof($attach_id_array))
{
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)))
{
if (!(DB()->sql_query($sql))) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
//bt
if ($sql_id == 'post_id')
{
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))
{
if (!$result = DB()->sql_query($sql)) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
$torrents_sql = array();
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$torrents_sql[] = $row['topic_id'];
}
if ($torrents_sql = implode(',', $torrents_sql))
{
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))
{
if (!DB()->sql_query($sql)) {
bb_die('Could not delete peers');
}
}
@ -197,65 +183,54 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
$sql = "DELETE FROM " . BB_BT_TORRENTS . "
WHERE attach_id IN(" . implode(',', $attach_id_array) . ")";
if (!DB()->sql_query($sql))
{
if (!DB()->sql_query($sql)) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
}
//bt end
for ($i = 0; $i < sizeof($attach_id_array); $i++)
{
for ($i = 0; $i < sizeof($attach_id_array); $i++) {
$sql = 'SELECT attach_id
FROM ' . BB_ATTACHMENTS . '
WHERE attach_id = ' . (int)$attach_id_array[$i];
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select Attachment id #2');
}
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows == 0)
{
if ($num_rows == 0) {
$sql = 'SELECT attach_id, physical_filename, thumbnail
FROM ' . BB_ATTACHMENTS_DESC . '
WHERE attach_id = ' . (int)$attach_id_array[$i];
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query attach description table');
}
$num_rows = DB()->num_rows($result);
if ($num_rows != 0)
{
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++)
{
for ($j = 0; $j < $num_attach; $j++) {
unlink_attach($attachments[$j]['physical_filename']);
if (intval($attachments[$j]['thumbnail']) == 1)
{
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'];
if (!(DB()->sql_query($sql)))
{
if (!(DB()->sql_query($sql))) {
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
}
}
else
{
} else {
DB()->sql_freeresult($result);
}
}
@ -263,20 +238,17 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
// Now Sync the Topic/PM
if (sizeof($post_id_array))
{
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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select topic id');
}
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
attachment_sync_topic($row['topic_id']);
}
DB()->sql_freeresult($result);

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.
*/
/**
* All Attachment Functions needed to determine Special Files/Dimensions
@ -12,8 +35,7 @@ function read_longint($fp)
$data = fread($fp, 4);
$value = ord($data[0]) + (ord($data[1]) << 8) + (ord($data[2]) << 16) + (ord($data[3]) << 24);
if ($value >= 4294967294)
{
if ($value >= 4294967294) {
$value -= 4294967296;
}
@ -49,73 +71,59 @@ function read_byte($fp)
*/
function image_getdimension($file)
{
$size = @getimagesize($file);
if ($size[0] != 0 || $size[1] != 0)
{
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)
{
if (!$fp) {
return $size;
}
$error = FALSE;
$error = false;
// BMP - IMAGE
$tmp_str = fread($fp, 2);
if ($tmp_str == 'BM')
{
if ($tmp_str == 'BM') {
$length = read_longint($fp);
if ($length <= 6)
{
if ($length <= 6) {
$error = true;
}
if (!$error)
{
if (!$error) {
$i = read_longint($fp);
if ( $i != 0)
{
if ($i != 0) {
$error = true;
}
}
if (!$error)
{
if (!$error) {
$i = read_longint($fp);
if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36)
{
if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36) {
$error = true;
}
}
if (!$error)
{
if (!$error) {
$tmp_str = fread($fp, 4);
$width = read_longint($fp);
$height = read_longint($fp);
if ($width > 3000 || $height > 3000)
{
if ($width > 3000 || $height > 3000) {
$error = true;
}
}
}
else
{
} else {
$error = true;
}
if (!$error)
{
if (!$error) {
fclose($fp);
return array(
$width,
@ -133,35 +141,27 @@ function image_getdimension($file)
$tmp_str = fread($fp, 3);
if ($tmp_str == 'GIF')
{
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)
{
if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0) {
$error = true;
}
if (!$error)
{
if (($info_byte & 8) != 0)
{
if (!$error) {
if (($info_byte & 8) != 0) {
$error = true;
}
}
} else {
$error = true;
}
}
}
else
{
$error = true;
}
if (!$error)
{
if (!$error) {
fclose($fp);
return array(
$width,
@ -179,52 +179,41 @@ function image_getdimension($file)
$tmp_str = fread($fp, 4);
$w1 = read_word($fp);
if (intval($w1) < 16)
{
if (intval($w1) < 16) {
$error = true;
}
if (!$error)
{
if (!$error) {
$tmp_str = fread($fp, 4);
if ($tmp_str == 'JFIF')
{
if ($tmp_str == 'JFIF') {
$o_byte = fread($fp, 1);
if (intval($o_byte) != 0)
{
if (intval($o_byte) != 0) {
$error = true;
}
if (!$error)
{
if (!$error) {
$str = fread($fp, 2);
$b = read_byte($fp);
if ($b != 0 && $b != 1 && $b != 2)
{
if ($b != 0 && $b != 1 && $b != 2) {
$error = true;
}
}
if (!$error)
{
if (!$error) {
$width = read_word($fp);
$height = read_word($fp);
if ($width <= 0 || $height <= 0)
{
if ($width <= 0 || $height <= 0) {
$error = true;
}
}
}
}
else
{
} else {
$error = true;
}
if (!$error)
{
if (!$error) {
fclose($fp);
return array(
$width,
@ -242,17 +231,14 @@ function image_getdimension($file)
$tmp_str = fread($fp, 3);
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))
{
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 (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24)
{
if (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24) {
$error = true;
}
if (!$error)
{
if (!$error) {
$xmin = read_word($fp);
$ymin = read_word($fp);
$xmax = read_word($fp);
@ -260,25 +246,20 @@ function image_getdimension($file)
$tmp_str = fread($fp, 52);
$b = fread($fp, 1);
if ($b != 0)
{
if ($b != 0) {
$error = true;
}
}
if (!$error)
{
if (!$error) {
$width = $xmax - $xmin + 1;
$height = $ymax - $ymin + 1;
}
}
else
{
} else {
$error = true;
}
if (!$error)
{
if (!$error) {
fclose($fp);
return array(
$width,

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.
*/
/**
* Setup s_auth_can in viewforum and viewtopic (viewtopic.php/viewforum.php)
@ -7,8 +30,7 @@ function attach_build_auth_levels($is_auth, &$s_auth_can)
{
global $lang, $attach_config;
if (intval($attach_config['disable_mod']))
{
if (intval($attach_config['disable_mod'])) {
return;
}
@ -24,92 +46,70 @@ function attachment_quota_settings($admin_mode, $submit = false, $mode)
{
global $template, $lang, $attach_config;
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
{
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
$upload_dir = $attach_config['upload_dir'];
}
else
{
} else {
$upload_dir = BB_ROOT . $attach_config['upload_dir'];
}
include(ATTACH_DIR . 'includes/functions_selects.php');
if (!function_exists("process_quota_settings"))
if (!function_exists("process_quota_settings")) {
include(ATTACH_DIR . 'includes/functions_admin.php');
}
$user_id = 0;
if ($admin_mode == 'user')
{
if ($admin_mode == 'user') {
// We overwrite submit here... to be sure
$submit = (isset($_POST['submit'])) ? true : false;
if (!$submit && $mode != 'save')
{
if (!$submit && $mode != 'save') {
$user_id = get_var(POST_USERS_URL, 0);
$u_name = get_var('username', '');
if (!$user_id && !$u_name)
{
if (!$user_id && !$u_name) {
bb_die($lang['NO_USER_ID_SPECIFIED']);
}
if ($user_id)
{
if ($user_id) {
$this_userdata['user_id'] = $user_id;
}
else
{
} else {
// Get userdata is handling the sanitizing of username
$this_userdata = get_userdata($_POST['username'], true);
}
$user_id = (int)$this_userdata['user_id'];
}
else
{
} else {
$user_id = get_var('id', 0);
if (!$user_id)
{
if (!$user_id) {
bb_die($lang['NO_USER_ID_SPECIFIED']);
}
}
}
if ($admin_mode == 'user' && !$submit && $mode != 'save')
{
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)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to get quota settings #1');
}
$pm_quota = $upload_quota = 0;
if ($row = DB()->sql_fetchrow($result))
{
do
{
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT)
{
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)
{
} elseif ($row['quota_type'] == QUOTA_PM_LIMIT) {
$pm_quota = $row['quota_limit_id'];
}
}
while ($row = DB()->sql_fetchrow($result));
}
else
{
} 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);
@ -119,13 +119,10 @@ function attachment_quota_settings($admin_mode, $submit = false, $mode)
));
}
if ($admin_mode == 'user' && $submit && @$_POST['delete_user'])
{
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')
{
} 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);
@ -134,43 +131,32 @@ function attachment_quota_settings($admin_mode, $submit = false, $mode)
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota);
}
if ($admin_mode == 'group' && $mode == 'newgroup')
{
if ($admin_mode == 'group' && $mode == 'newgroup') {
return;
}
if ($admin_mode == 'group' && !$submit && isset($_POST['edit']))
{
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;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Unable to get quota settings #2');
}
$pm_quota = $upload_quota = 0;
if ($row = DB()->sql_fetchrow($result))
{
do
{
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT)
{
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)
{
} elseif ($row['quota_type'] == QUOTA_PM_LIMIT) {
$pm_quota = $row['quota_limit_id'];
}
}
while ($row = DB()->sql_fetchrow($result));
}
else
{
} 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'];
@ -183,15 +169,12 @@ function attachment_quota_settings($admin_mode, $submit = false, $mode)
));
}
if ($admin_mode == 'group' && $submit && isset($_POST['group_delete']))
{
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);
}
else if ($admin_mode == 'group' && $submit)
{
} elseif ($admin_mode == 'group' && $submit) {
$group_id = get_var(POST_GROUPS_URL, 0);
// Get the contents

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.
*/
/**
* Functions to build select boxes ;)
@ -13,8 +36,7 @@ function group_select($select_name, $default_group = 0)
$sql = 'SELECT group_id, group_name FROM ' . BB_EXTENSION_GROUPS . ' ORDER BY group_name';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query extension groups table #1');
}
@ -24,19 +46,14 @@ function group_select($select_name, $default_group = 0)
$num_rows = DB()->num_rows($result);
DB()->sql_freeresult($result);
if ($num_rows > 0)
{
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)
{
for ($i = 0; $i < sizeof($group_name); $i++) {
if (!$default_group) {
$selected = ($i == 0) ? ' selected="selected"' : '';
}
else
{
} else {
$selected = ($group_name[$i]['group_id'] == $default_group) ? ' selected="selected"' : '';
}
@ -56,21 +73,18 @@ function download_select($select_name, $group_id = 0)
{
global $types_download, $modes_download;
if ($group_id)
{
if ($group_id) {
$sql = 'SELECT download_mode
FROM ' . BB_EXTENSION_GROUPS . '
WHERE group_id = ' . (int)$group_id;
if (!($result = DB()->sql_query($sql)))
{
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']))
{
if (!isset($row['download_mode'])) {
return '';
}
@ -79,14 +93,10 @@ function download_select($select_name, $group_id = 0)
$group_select = '<select name="' . $select_name . '">';
for ($i = 0; $i < sizeof($types_download); $i++)
{
if (!$group_id)
{
for ($i = 0; $i < sizeof($types_download); $i++) {
if (!$group_id) {
$selected = ($types_download[$i] == INLINE_LINK) ? ' selected="selected"' : '';
}
else
{
} else {
$selected = ($row['download_mode'] == $types_download[$i]) ? ' selected="selected"' : '';
}
@ -107,8 +117,7 @@ function category_select($select_name, $group_id = 0)
$sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS;
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not select category');
}
@ -118,12 +127,9 @@ function category_select($select_name, $group_id = 0)
$type_category = 0;
if ($num_rows > 0)
{
for ($i = 0; $i < $num_rows; $i++)
{
if ($group_id == $rows[$i]['group_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'];
}
}
@ -132,22 +138,17 @@ function category_select($select_name, $group_id = 0)
$types = array(NONE_CAT);
$modes = array('none');
for ($i = 0; $i < sizeof($types_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">';
for ($i = 0; $i < sizeof($types); $i++)
{
if (!$group_id)
{
for ($i = 0; $i < sizeof($types); $i++) {
if (!$group_id) {
$selected = ($types[$i] == NONE_CAT) ? ' selected="selected"' : '';
}
else
{
} else {
$selected = ($types[$i] == $category_type) ? ' selected="selected"' : '';
}
@ -171,8 +172,7 @@ function size_select($select_name, $size_compare)
$select_field = '<select name="' . $select_name . '">';
for ($i = 0; $i < sizeof($size_types_text); $i++)
{
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>';
}
@ -191,8 +191,7 @@ function quota_limit_select($select_name, $default_quota = 0)
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query quota limits table #1');
}
@ -200,14 +199,12 @@ function quota_limit_select($select_name, $default_quota = 0)
$quota_name[0]['quota_limit_id'] = 0;
$quota_name[0]['quota_desc'] = $lang['NOT_ASSIGNED'];
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$quota_name[] = $row;
}
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($quota_name); $i++)
{
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>';
}
@ -225,8 +222,7 @@ function default_quota_limit_select($select_name, $default_quota = 0)
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
if (!($result = DB()->sql_query($sql)))
{
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not query quota limits table #2');
}
@ -234,14 +230,12 @@ function default_quota_limit_select($select_name, $default_quota = 0)
$quota_name[0]['quota_limit_id'] = 0;
$quota_name[0]['quota_desc'] = $lang['NO_QUOTA_LIMIT'];
while ($row = DB()->sql_fetchrow($result))
{
while ($row = DB()->sql_fetchrow($result)) {
$quota_name[] = $row;
}
DB()->sql_freeresult($result);
for ($i = 0; $i < sizeof($quota_name); $i++)
{
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>';
}

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");
}
$imagick = '';
@ -12,15 +37,12 @@ function get_img_size_format($width, $height)
// Maximum Width the Image can take
$max_width = 400;
if ($width > $height)
{
if ($width > $height) {
return array(
round($width * ($max_width / $width)),
round($height * ($max_width / $width))
);
}
else
{
} else {
return array(
round($width * ($max_width / $height)),
round($height * ($max_width / $height))
@ -35,13 +57,10 @@ function is_imagick()
{
global $imagick, $attach_config;
if ($attach_config['img_imagick'] != '')
{
if ($attach_config['img_imagick'] != '') {
$imagick = $attach_config['img_imagick'];
return true;
}
else
{
} else {
return false;
}
}
@ -51,13 +70,11 @@ function is_imagick()
*/
function get_supported_image_types($type)
{
if (@extension_loaded('gd'))
{
if (@extension_loaded('gd')) {
$format = imagetypes();
$new_type = 0;
switch ($type)
{
switch ($type) {
case 1:
$new_type = ($format & IMG_GIF) ? IMG_GIF : 0;
break;
@ -98,15 +115,13 @@ function create_thumbnail($source, $new_file, $mimetype)
$min_filesize = (int)$attach_config['img_min_thumb_filesize'];
$img_filesize = (@file_exists($source)) ? @filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize)
{
if (!$img_filesize || $img_filesize <= $min_filesize) {
return false;
}
list($width, $height, $type,) = getimagesize($source);
if (!$width || !$height)
{
if (!$width || !$height) {
return false;
}
@ -116,23 +131,18 @@ function create_thumbnail($source, $new_file, $mimetype)
$used_imagick = false;
if (is_imagick())
{
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))
{
if (@file_exists($new_file)) {
$used_imagick = true;
}
}
if (!$used_imagick)
{
if (!$used_imagick) {
$type = get_supported_image_types($type);
if ($type['gd'])
{
switch ($type['format'])
{
if ($type['gd']) {
switch ($type['format']) {
case IMG_GIF:
$image = imagecreatefromgif($source);
break;
@ -147,19 +157,15 @@ function create_thumbnail($source, $new_file, $mimetype)
break;
}
if ($type['version'] == 1 || !$attach_config['use_gd2'])
{
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
{
} 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'])
{
switch ($type['format']) {
case IMG_GIF:
imagegif($new_image, $new_file);
break;
@ -178,8 +184,7 @@ function create_thumbnail($source, $new_file, $mimetype)
}
}
if (!@file_exists($new_file))
{
if (!@file_exists($new_file)) {
return false;
}

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
@ -60,7 +83,9 @@
* Local config
**/
if (!defined('BB_ROOT')) die(basename(__FILE__));
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$bb_cfg = $tr_cfg = $page_cfg = array();
@ -142,8 +167,7 @@ $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']))
{
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
@ -278,28 +302,19 @@ $bb_cfg['pm_url'] = 'privmsg.php'; # "http://{$domain_name}/privmsg.php"
$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'])
{
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 .'/'))
{
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
{
} 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'] .'/'))
{
} 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
{
} else {
$bb_cfg['default_lang_dir'] = LANG_ROOT_DIR . 'en/';
}
}
@ -434,9 +449,13 @@ 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');
@ -639,8 +658,7 @@ $bb_cfg['nofollow'] = array(
);
// Local config
if (file_exists(BB_ROOT. '/library/config.local.php'))
{
if (file_exists(BB_ROOT . '/library/config.local.php')) {
include_once(BB_ROOT . '/library/config.local.php');
}

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