diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php deleted file mode 100644 index 3d498d18b..000000000 --- a/admin/admin_attach_cp.php +++ /dev/null @@ -1,479 +0,0 @@ -'; - -for ($i = 0, $iMax = count($view_types_text); $i < $iMax; $i++) { - $selected = ($view === $view_types[$i]) ? ' selected="selected"' : ''; - $select_view .= ''; -} -$select_view .= ''; - -if (count($mode_types_text) > 0) { - $select_sort_mode = ''; -} - -$select_sort_order = ''; - -$submit_change = isset($_POST['submit_change']); -$delete = isset($_POST['delete']); -$delete_id_list = get_var('delete_id_list', array(0)); - -$confirm = isset($_POST['confirm']); - -if ($confirm && count($delete_id_list) > 0) { - $attachments = array(); - - delete_attachment(0, $delete_id_list); -} elseif ($delete && count($delete_id_list) > 0) { - // Not confirmed, show confirmation message - $hidden_fields = ''; - $hidden_fields .= ''; - $hidden_fields .= ''; - $hidden_fields .= ''; - $hidden_fields .= ''; - - foreach ($delete_id_list as $iValue) { - $hidden_fields .= ''; - } - - print_confirmation(array( - 'FORM_ACTION' => 'admin_attach_cp.php', - 'HIDDEN_FIELDS' => $hidden_fields, - )); -} - -// Assign Default Template Vars -$template->assign_vars(array( - 'S_VIEW_SELECT' => $select_view, - 'S_MODE_ACTION' => 'admin_attach_cp.php', -)); - -if ($submit_change && $view === 'attachments') { - $attach_change_list = get_var('attach_id_list', array(0)); - $attach_comment_list = get_var('attach_comment_list', array('')); - $attach_download_count_list = get_var('attach_count_list', array(0)); - - // Generate correct Change List - $attachments = array(); - - for ($i = 0, $iMax = count($attach_change_list); $i < $iMax; $i++) { - $attachments['_' . $attach_change_list[$i]]['comment'] = $attach_comment_list[$i]; - $attachments['_' . $attach_change_list[$i]]['download_count'] = $attach_download_count_list[$i]; - } - - $sql = 'SELECT * - FROM ' . BB_ATTACHMENTS_DESC . ' - ORDER BY attach_id'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get attachment informations'); - } - - while ($attachrow = DB()->sql_fetchrow($result)) { - if (isset($attachments['_' . $attachrow['attach_id']])) { - if ($attachrow['comment'] != $attachments['_' . $attachrow['attach_id']]['comment'] || $attachrow['download_count'] != $attachments['_' . $attachrow['attach_id']]['download_count']) { - $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . " - SET comment = '" . attach_mod_sql_escape($attachments['_' . $attachrow['attach_id']]['comment']) . "', download_count = " . (int)$attachments['_' . $attachrow['attach_id']]['download_count'] . ' - WHERE attach_id = ' . (int)$attachrow['attach_id']; - - if (!DB()->sql_query($sql)) { - bb_die('Could not update attachments informations'); - } - } - } - } - DB()->sql_freeresult($result); -} - -// Statistics -if ($view == 'stats') { - $upload_dir_size = get_formatted_dirsize(); - - $attachment_quota = humn_size($attach_config['attachment_quota']); - - // number_of_attachments - $row = DB()->fetch_row('SELECT COUNT(*) AS total FROM ' . BB_ATTACHMENTS_DESC); - $number_of_attachments = $number_of_posts = $row['total']; - - $number_of_pms = 0; - - // number_of_topics - $row = DB()->fetch_row('SELECT COUNT(*) AS topics FROM ' . BB_TOPICS . ' WHERE topic_attachment = 1'); - $number_of_topics = $row['topics']; - - // number_of_users - $row = DB()->fetch_row('SELECT COUNT(DISTINCT user_id_1) AS users FROM ' . BB_ATTACHMENTS . ' WHERE post_id != 0'); - $number_of_users = $row['users']; - - $template->assign_vars(array( - 'TPL_ATTACH_STATISTICS' => true, - 'TOTAL_FILESIZE' => $upload_dir_size, - 'ATTACH_QUOTA' => $attachment_quota, - 'NUMBER_OF_ATTACHMENTS' => $number_of_attachments, - 'NUMBER_OF_POSTS' => $number_of_posts, - 'NUMBER_OF_PMS' => $number_of_pms, - 'NUMBER_OF_TOPICS' => $number_of_topics, - 'NUMBER_OF_USERS' => $number_of_users, - )); -} - -// Search -if ($view === 'search') { - // Get Forums and Categories - //sf - add [, f.forum_parent] - $sql = 'SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id, f.forum_parent - FROM ' . BB_CATEGORIES . ' c, ' . BB_FORUMS . ' f - WHERE f.cat_id = c.cat_id - ORDER BY c.cat_id, f.forum_order'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not obtain forum_name / forum_id'); - } - - $s_forums = ''; - $list_cat = []; - while ($row = DB()->sql_fetchrow($result)) { //sf - $s_forums .= ''; - - if (empty($list_cat[$row['cat_id']])) { - $list_cat[$row['cat_id']] = $row['cat_title']; - } - } - - $s_categories = ''; - if ($s_forums) { - $s_forums = '' . $s_forums; - - // Category to search - $s_categories = ''; - - foreach ($list_cat as $cat_id => $cat_title) { - $s_categories .= ''; - } - } else { - bb_die($lang['NO_SEARCHABLE_FORUMS']); - } - - $template->assign_vars(array( - 'TPL_ATTACH_SEARCH' => true, - 'S_FORUM_OPTIONS' => $s_forums, - 'S_CATEGORY_OPTIONS' => $s_categories, - 'S_SORT_OPTIONS' => $select_sort_mode, - 'S_SORT_ORDER' => $select_sort_order, - )); -} - -// Username -if ($view === 'username') { - $template->assign_vars(array( - 'TPL_ATTACH_USER' => true, - 'S_MODE_SELECT' => $select_sort_mode, - 'S_ORDER_SELECT' => $select_sort_order, - )); - $total_rows = 0; - bb_die('removed'); -} - -// Attachments -if ($view === 'attachments') { - $user_based = $uid ? true : false; - $search_based = (isset($_POST['search']) && $_POST['search']); - - $hidden_fields = ''; - - $template->assign_vars(array( - 'TPL_ATTACH_ATTACHMENTS' => true, - 'S_MODE_SELECT' => $select_sort_mode, - 'S_ORDER_SELECT' => $select_sort_order, - )); - - $total_rows = 0; - - // Are we called from Username ? - if ($user_based) { - $sql = 'SELECT username FROM ' . BB_USERS . ' WHERE user_id = ' . (int)$uid; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Error getting username'); - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - $username = $row['username']; - - $s_hidden = ''; - - $template->assign_block_vars('switch_user_based', array()); - - $template->assign_vars(array( - 'S_USER_HIDDEN' => $s_hidden, - 'L_STATISTICS_FOR_USER' => sprintf($lang['STATISTICS_FOR_USER'], $username), - )); - - $sql = 'SELECT attach_id - FROM ' . BB_ATTACHMENTS . ' - WHERE user_id_1 = ' . (int)$uid . ' - GROUP BY attach_id'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query attachments #1'); - } - - $attach_ids = DB()->sql_fetchrowset($result); - $num_attach_ids = DB()->num_rows($result); - DB()->sql_freeresult($result); - - if ($num_attach_ids == 0) { - bb_die('For some reason no attachments are assigned to the user ' . $username); - } - - $total_rows = $num_attach_ids; - - $attach_id = array(); - - for ($j = 0; $j < $num_attach_ids; $j++) { - $attach_id[] = (int)$attach_ids[$j]['attach_id']; - } - - $sql = 'SELECT a.* - FROM ' . BB_ATTACHMENTS_DESC . ' a - WHERE a.attach_id IN (' . implode(', ', $attach_id) . ') ' . - $order_by; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query attachments #2'); - } - - $attachments = DB()->sql_fetchrowset($result); - $num_attach = DB()->num_rows($result); - DB()->sql_freeresult($result); - } else { - // we are called from search - $attachments = search_attachments($order_by, $total_rows); - } - - if (count($attachments) > 0) { - for ($i = 0, $iMax = count($attachments); $i < $iMax; $i++) { - $delete_box = ''; - - foreach ($delete_id_list as $jValue) { - if ($jValue == $attachments[$i]['attach_id']) { - $delete_box = ''; - break; - } - } - - $row_class = !($i % 2) ? 'row1' : 'row2'; - - // Is the Attachment assigned to more than one post ? - // If it's not assigned to any post, it's an private message thingy. ;) - $post_titles = []; - - $sql = 'SELECT * - FROM ' . BB_ATTACHMENTS . ' - WHERE attach_id = ' . (int)$attachments[$i]['attach_id']; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query attachments #3'); - } - - $ids = DB()->sql_fetchrowset($result); - $num_ids = DB()->num_rows($result); - DB()->sql_freeresult($result); - - 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 = ' . (int)$ids[$j]['post_id'] . ' AND p.topic_id = t.topic_id - GROUP BY t.topic_id, t.topic_title'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query topic'); - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - $post_title = $row['topic_title']; - - if (strlen($post_title) > 32) { - $post_title = str_short($post_title, 30); - } - - $view_topic = BB_ROOT . 'viewtopic.php?' . POST_POST_URL . '=' . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id']; - - $post_titles[] = '' . $post_title . ''; - } else { - $post_titles[] = $lang['PRIVATE_MESSAGE']; - } - } - - $post_titles = implode('
', $post_titles); - - $hidden_field = ''; - - $template->assign_block_vars('attachrow', array( - 'ROW_NUMBER' => $i + ($_GET['start'] + 1), - 'ROW_CLASS' => $row_class, - - 'FILENAME' => htmlspecialchars($attachments[$i]['real_filename']), - 'COMMENT' => htmlspecialchars($attachments[$i]['comment']), - 'EXTENSION' => $attachments[$i]['extension'], - 'SIZE' => round($attachments[$i]['filesize'] / 1024, 2), - 'DOWNLOAD_COUNT' => $attachments[$i]['download_count'], - 'POST_TIME' => bb_date($attachments[$i]['filetime']), - 'POST_TITLE' => $post_titles, - - 'S_DELETE_BOX' => $delete_box, - 'S_HIDDEN' => $hidden_field, - 'U_VIEW_ATTACHMENT' => BB_ROOT . DL_URL . $attachments[$i]['attach_id'], - )); - } - } - - if (!$search_based && !$user_based) { - if (!$attachments) { - $sql = 'SELECT attach_id FROM ' . BB_ATTACHMENTS_DESC; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query attachment description table'); - } - - $total_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - } - } -} - -// Generate Pagination -if ($do_pagination && $total_rows > $bb_cfg['topics_per_page']) { - generate_pagination('admin_attach_cp.php?view=' . $view . '&mode=' . $mode . '&order=' . $sort_order . '&uid=' . $uid, $total_rows, $bb_cfg['topics_per_page'], $start); -} - -print_page('admin_attach_cp.tpl', 'admin'); diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php deleted file mode 100644 index 4ba0d08e0..000000000 --- a/admin/admin_attachments.php +++ /dev/null @@ -1,597 +0,0 @@ -sql_query($sql)) { - bb_die('Could not find attachment config table #1'); -} - -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') { - $size = ($attach_config[$config_name] >= 1048576) ? 'mb' : (($attach_config[$config_name] >= 1024) ? 'kb' : 'b'); - } - - 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') { - $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) { - $new_attach[$config_name] = round($new_attach[$config_name] / 1048576 * 100) / 100; - } 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') { - $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') { - $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') { - $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') { - $old_size = $attach_config[$config_name]; - $new_size = $new_attach[$config_name]; - - 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))) { - 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 { - $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)) { - bb_die('Failed to update attachment configuration for ' . $config_name); - } - - if ($config_name == 'max_filesize' || $config_name == 'attachment_quota' || $config_name == 'max_filesize_pm') { - $new_attach[$config_name] = $old; - } - } -} -DB()->sql_freeresult($result); - -// Clear cached config -CACHE('bb_cache')->rm('attach_config'); - -$select_size_mode = size_select('size', $size); -$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) { - $imagick = ''; - - if (false !== stripos($imagick, "convert")) { - return true; - } - - if ($imagick != 'none') { - if (!false !== stripos(PHP_OS, "WIN")) { - $retval = @exec('whereis convert'); - $paths = explode(' ', $retval); - - if (is_array($paths)) { - foreach ($paths as $i => $iValue) { - $path = basename($paths[$i]); - - if ($path == 'convert') { - $imagick = $iValue; - } - } - } - } elseif (false !== stripos(PHP_OS, "WIN")) { - $path = 'c:/imagemagick/convert.exe'; - - if (!@file_exists(amod_realpath($path))) { - $imagick = $path; - } - } - } - - if (!@file_exists(amod_realpath(trim($imagick)))) { - $new_attach['img_imagick'] = trim($imagick); - } else { - $new_attach['img_imagick'] = ''; - } -} - -// Check Settings -if ($check_upload) { - // Some tests... - $attach_config = array(); - - $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not find attachment config table #2'); - } - - $row = DB()->sql_fetchrowset($result); - $num_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - - 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] == ':')) { - $upload_dir = $attach_config['upload_dir']; - } 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))) { - $error = true; - $error_msg = sprintf($lang['DIRECTORY_DOES_NOT_EXIST'], $attach_config['upload_dir']) . '
'; - } - - if (!$error && !is_dir($upload_dir)) { - $error = true; - $error_msg = sprintf($lang['DIRECTORY_IS_NOT_A_DIR'], $attach_config['upload_dir']) . '
'; - } - - if (!$error) { - if (!($fp = @fopen($upload_dir . '/0_000000.000', 'wb'))) { - $error = true; - $error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $attach_config['upload_dir']) . '
'; - } else { - @fclose($fp); - unlink_attach($upload_dir . '/0_000000.000'); - } - } - - if (!$error) { - bb_die($lang['TEST_SETTINGS_SUCCESSFUL'] . '

' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); - } -} - -// Management -if ($submit && $mode == 'manage') { - if (!$error) { - bb_die($lang['ATTACH_CONFIG_UPDATED'] . '

' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); - } -} - -if ($mode == 'manage') { - $template->assign_vars(array( - 'TPL_ATTACH_MANAGE' => true, - 'S_ATTACH_ACTION' => 'admin_attachments.php?mode=manage', - 'S_FILESIZE' => $select_size_mode, - 'S_FILESIZE_QUOTA' => $select_quota_size_mode, - 'S_FILESIZE_PM' => $select_pm_size_mode, - 'S_DEFAULT_UPLOAD_LIMIT' => default_quota_limit_select('default_upload_quota', (int)trim($new_attach['default_upload_quota'])), - 'S_DEFAULT_PM_LIMIT' => default_quota_limit_select('default_pm_quota', (int)trim($new_attach['default_pm_quota'])), - - 'UPLOAD_DIR' => $new_attach['upload_dir'], - 'ATTACHMENT_IMG_PATH' => $new_attach['upload_img'], - 'TOPIC_ICON' => $new_attach['topic_icon'], - 'MAX_FILESIZE' => $new_attach['max_filesize'], - 'ATTACHMENT_QUOTA' => $new_attach['attachment_quota'], - 'MAX_FILESIZE_PM' => $new_attach['max_filesize_pm'], - 'MAX_ATTACHMENTS' => $new_attach['max_attachments'], - 'MAX_ATTACHMENTS_PM' => $new_attach['max_attachments_pm'], - 'DISABLE_MOD_YES' => $new_attach['disable_mod'] !== '0' ? 'checked="checked"' : '', - 'DISABLE_MOD_NO' => $new_attach['disable_mod'] === '0' ? 'checked="checked"' : '', - 'PM_ATTACH_YES' => $new_attach['allow_pm_attach'] !== '0' ? 'checked="checked"' : '', - 'PM_ATTACH_NO' => $new_attach['allow_pm_attach'] === '0' ? 'checked="checked"' : '', - 'DISPLAY_ORDER_ASC' => $new_attach['display_order'] !== '0' ? 'checked="checked"' : '', - 'DISPLAY_ORDER_DESC' => $new_attach['display_order'] === '0' ? 'checked="checked"' : '', - )); -} - -if ($submit && $mode == 'cats') { - if (!$error) { - bb_die($lang['ATTACH_CONFIG_UPDATED'] . '

' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); - } -} - -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))) { - bb_die('Could not get group names from ' . BB_EXTENSION_GROUPS); - } - - $row = DB()->sql_fetchrowset($result); - DB()->sql_freeresult($result); - - for ($i = 0, $iMax = count($row); $i < $iMax; $i++) { - if ($row[$i]['cat_id'] == IMAGE_CAT) { - $s_assigned_group_images[] = $row[$i]['group_name']; - } - } - - $display_inlined_yes = ($new_attach['img_display_inlined'] != '0') ? 'checked="checked"' : ''; - $display_inlined_no = ($new_attach['img_display_inlined'] == '0') ? 'checked="checked"' : ''; - - $create_thumbnail_yes = ($new_attach['img_create_thumbnail'] != '0') ? 'checked="checked"' : ''; - $create_thumbnail_no = ($new_attach['img_create_thumbnail'] == '0') ? 'checked="checked"' : ''; - - $use_gd2_yes = ($new_attach['use_gd2'] != '0') ? 'checked="checked"' : ''; - $use_gd2_no = ($new_attach['use_gd2'] == '0') ? 'checked="checked"' : ''; - - // Check Thumbnail Support - if (!is_imagick() && !@extension_loaded('gd')) { - $new_attach['img_create_thumbnail'] = '0'; - } else { - $template->assign_block_vars('switch_thumbnail_support', array()); - } - - $template->assign_vars(array( - 'TPL_ATTACH_SPECIAL_CATEGORIES' => true, - 'IMAGE_MAX_HEIGHT' => $new_attach['img_max_height'], - 'IMAGE_MAX_WIDTH' => $new_attach['img_max_width'], - 'IMAGE_LINK_HEIGHT' => $new_attach['img_link_height'], - 'IMAGE_LINK_WIDTH' => $new_attach['img_link_width'], - 'IMAGE_MIN_THUMB_FILESIZE' => $new_attach['img_min_thumb_filesize'], - 'IMAGE_IMAGICK_PATH' => $new_attach['img_imagick'], - 'DISPLAY_INLINED_YES' => $display_inlined_yes, - 'DISPLAY_INLINED_NO' => $display_inlined_no, - 'CREATE_THUMBNAIL_YES' => $create_thumbnail_yes, - 'CREATE_THUMBNAIL_NO' => $create_thumbnail_no, - 'USE_GD2_YES' => $use_gd2_yes, - 'USE_GD2_NO' => $use_gd2_no, - 'S_ASSIGNED_GROUP_IMAGES' => implode(', ', $s_assigned_group_images), - 'S_ATTACH_ACTION' => 'admin_attachments.php?mode=cats', - )); -} - -// Check Cat Settings -if ($check_image_cat) { - // Some tests... - $attach_config = array(); - - $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not find attachment config table #3'); - } - - $row = DB()->sql_fetchrowset($result); - $num_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - - 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] == ':')) { - $upload_dir = $attach_config['upload_dir']; - } else { - $upload_dir = BB_ROOT . $attach_config['upload_dir']; - } - - $upload_dir = $upload_dir . '/' . THUMB_DIR; - - $error = false; - - // Does the target directory exist, is it a directory and writeable - if (!@file_exists(amod_realpath($upload_dir))) { - if (!mkdir($upload_dir, 0755) && !is_dir($upload_dir)) { - throw new \RuntimeException(sprintf('Directory "%s" was not created', $upload_dir)); - } - @chmod($upload_dir, 0777); - - if (!@file_exists(amod_realpath($upload_dir))) { - $error = true; - $error_msg = sprintf($lang['DIRECTORY_DOES_NOT_EXIST'], $upload_dir) . '
'; - } - } - - if (!$error && !is_dir($upload_dir)) { - $error = true; - $error_msg = sprintf($lang['DIRECTORY_IS_NOT_A_DIR'], $upload_dir) . '
'; - } - - if (!$error) { - if (!($fp = @fopen($upload_dir . '/0_000000.000', 'wb'))) { - $error = true; - $error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $upload_dir) . '
'; - } else { - @fclose($fp); - @unlink($upload_dir . '/0_000000.000'); - } - } - - if (!$error) { - bb_die($lang['TEST_SETTINGS_SUCCESSFUL'] . '

' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); - } -} - -// Quota Limit Settings -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('')); - $filesize_list = get_var('max_filesize_list', array(0)); - $size_select_list = get_var('size_select_list', array('')); - - $allowed_list = array(); - - for ($i = 0, $iMax = count($quota_change_list); $i < $iMax; $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)) { - bb_die('Could not update quota limits'); - } - } - - // Delete Quota Limits - $quota_id_list = get_var('quota_id_list', array(0)); - - $quota_id_sql = implode(', ', $quota_id_list); - - if ($quota_id_sql != '') { - $sql = 'DELETE FROM ' . BB_QUOTA_LIMITS . ' WHERE quota_limit_id IN (' . $quota_id_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))) { - bb_die('Could not delete quotas'); - } - } - - // Add Quota Limit ? - $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; - - if ($quota_desc != '' && $add) { - // check Quota Description - $sql = 'SELECT quota_desc FROM ' . BB_QUOTA_LIMITS; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query quota limits table'); - } - - $row = DB()->sql_fetchrowset($result); - $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)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['QUOTA_LIMIT_EXIST'], $extension_group); - } - } - } - - 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)) { - bb_die('Could not add quota limit'); - } - } - } - - if (!$error) { - bb_die($lang['ATTACH_CONFIG_UPDATED'] . '

' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); - } -} - -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) { - $max_add_filesize = round($max_add_filesize / 1048576 * 100) / 100; - } elseif ($max_add_filesize >= 1024) { - $max_add_filesize = round($max_add_filesize / 1024 * 100) / 100; - } - - $template->assign_vars(array( - 'TPL_ATTACH_QUOTA' => true, - 'MAX_FILESIZE' => $max_add_filesize, - 'S_FILESIZE' => size_select('add_size_select', $size), - 'S_ATTACH_ACTION' => 'admin_attachments.php?mode=quota', - )); - - $sql = 'SELECT * FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit DESC'; - - 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, $iMax = count($rows); $i < $iMax; $i++) { - $size_format = ($rows[$i]['quota_limit'] >= 1048576) ? 'mb' : (($rows[$i]['quota_limit'] >= 1024) ? 'kb' : 'b'); - - if ($rows[$i]['quota_limit'] >= 1048576) { - $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1048576 * 100) / 100; - } elseif ($rows[$i]['quota_limit'] >= 1024) { - $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1024 * 100) / 100; - } - - $template->assign_block_vars('limit_row', array( - 'QUOTA_NAME' => $rows[$i]['quota_desc'], - 'QUOTA_ID' => $rows[$i]['quota_limit_id'], - 'S_FILESIZE' => size_select('size_select_list[]', $size_format), - 'U_VIEW' => "admin_attachments.php?mode=$mode&e_mode=view_quota&quota_id=" . $rows[$i]['quota_limit_id'], - 'MAX_FILESIZE' => $rows[$i]['quota_limit'], - )); - } -} - -if ($mode == 'quota' && $e_mode == 'view_quota') { - $quota_id = get_var('quota_id', 0); - - if (!$quota_id) { - bb_die('Invalid call'); - } - - $template->assign_block_vars('switch_quota_limit_desc', array()); - - $sql = 'SELECT * FROM ' . BB_QUOTA_LIMITS . ' WHERE quota_limit_id = ' . (int)$quota_id . ' LIMIT 1'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get quota limits #2'); - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - - $template->assign_vars(array( - 'L_QUOTA_LIMIT_DESC' => $row['quota_desc'], - )); - - $sql = 'SELECT q.user_id, u.username, q.quota_type - FROM ' . BB_QUOTA . ' q, ' . BB_USERS . ' u - WHERE q.quota_limit_id = ' . (int)$quota_id . ' - AND q.user_id <> 0 - AND q.user_id = u.user_id'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get quota limits #3'); - } - - $rows = DB()->sql_fetchrowset($result); - $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) { - $template->assign_block_vars('users_upload_row', array( - 'USER_ID' => $rows[$i]['user_id'], - 'USERNAME' => $rows[$i]['username'], - )); - } 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'], - )); - } - } - - $sql = 'SELECT q.group_id, g.group_name, q.quota_type - FROM ' . BB_QUOTA . ' q, ' . BB_GROUPS . ' g - WHERE q.quota_limit_id = ' . (int)$quota_id . ' - AND q.group_id <> 0 - AND q.group_id = g.group_id'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get quota limits #4'); - } - - $rows = DB()->sql_fetchrowset($result); - $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) { - $template->assign_block_vars('groups_upload_row', array( - 'GROUP_ID' => $rows[$i]['group_id'], - 'GROUPNAME' => $rows[$i]['group_name'], - )); - } 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'], - )); - } - } -} - -if ($error) { - $template->assign_vars(array('ERROR_MESSAGE' => $error_msg)); -} - -print_page('admin_attachments.tpl', 'admin'); diff --git a/admin/admin_extensions.php b/admin/admin_extensions.php deleted file mode 100644 index a9899e500..000000000 --- a/admin/admin_extensions.php +++ /dev/null @@ -1,672 +0,0 @@ -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] == ':'))) { - $upload_dir = $attach_config['upload_dir']; -} else { - $upload_dir = BB_ROOT . $attach_config['upload_dir']; -} - -include ATTACH_DIR . '/includes/functions_selects.php'; - -// Init Vars -$types_download = array(INLINE_LINK, PHYSICAL_LINK); -$modes_download = array('inline', 'physical'); - -$types_category = array(IMAGE_CAT); -$modes_category = array($lang['CATEGORY_IMAGES']); - -$size = get_var('size', ''); -$mode = get_var('mode', ''); -$e_mode = get_var('e_mode', ''); - -$error = false; -$add_forum = isset($_POST['add_forum']) ? true : false; -$delete_forum = isset($_POST['del_forum']) ? 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))) { - bb_die('Could not query attachment information'); -} - -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') { - // Change Extensions ? - $extension_change_list = get_var('extension_change_list', array(0)); - $extension_explain_list = get_var('extension_explain_list', array('')); - $group_select_list = get_var('group_select', array(0)); - - // Generate correct Change List - $extensions = array(); - - for ($i = 0, $iMax = count($extension_change_list); $i < $iMax; $i++) { - $extensions['_' . $extension_change_list[$i]]['comment'] = $extension_explain_list[$i]; - $extensions['_' . $extension_change_list[$i]]['group_id'] = (int)$group_select_list[$i]; - } - - $sql = 'SELECT * FROM ' . BB_EXTENSIONS . ' ORDER BY ext_id'; - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get extension informations #1'); - } - - $num_rows = DB()->num_rows($result); - $extension_row = DB()->sql_fetchrowset($result); - DB()->sql_freeresult($result); - - if ($num_rows > 0) { - for ($i = 0, $iMax = count($extension_row); $i < $iMax; $i++) { - if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || (int)$extension_row[$i]['group_id'] != (int)$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'] - ); - - $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)) { - bb_die('Could not update extension informations'); - } - } - } - } - - // Delete Extension? - $extension_id_list = get_var('extension_id_list', array(0)); - - $extension_id_sql = implode(', ', $extension_id_list); - - if ($extension_id_sql != '') { - $sql = 'DELETE FROM ' . BB_EXTENSIONS . ' WHERE ext_id IN (' . $extension_id_sql . ')'; - - if (!$result = DB()->sql_query($sql)) { - bb_die('Could not delete extensions'); - } - } - - // Add Extension ? - $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; - - if ($extension != '' && $add) { - $template->assign_vars(array( - 'ADD_EXTENSION' => $extension, - 'ADD_EXTENSION_EXPLAIN' => $extension_explain, - )); - - if (!$error) { - // check extension - $sql = 'SELECT extension FROM ' . BB_EXTENSIONS; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query extensions'); - } - - $row = DB()->sql_fetchrowset($result); - $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)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['EXTENSION_EXIST'], strtolower(trim($extension))); - } - } - } - - if (!$error) { - $sql_ary = array( - 'group_id' => (int)$extension_group, - 'extension' => (string)strtolower($extension), - 'comment' => (string)$extension_explain - ); - - $sql = 'INSERT INTO ' . BB_EXTENSIONS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary); - - if (!DB()->sql_query($sql)) { - bb_die('Could not add extension'); - } - } - } - } - - if (!$error) { - bb_die($lang['ATTACH_CONFIG_UPDATED'] . '

' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); - } -} - -if ($mode == 'extensions') { - // Extensions - $template->assign_vars(array( - 'TPL_ATTACH_EXTENSIONS' => true, - 'S_CANCEL_ACTION' => 'admin_extensions.php?mode=extensions', - 'S_ATTACH_ACTION' => 'admin_extensions.php?mode=extensions', - )); - - if ($submit) { - $template->assign_vars(array( - 'S_ADD_GROUP_SELECT' => group_select('add_group_select', $extension_group)) - ); - } else { - $template->assign_vars(array( - 'S_ADD_GROUP_SELECT' => group_select('add_group_select')) - ); - } - - $sql = 'SELECT * FROM ' . BB_EXTENSIONS . ' ORDER BY group_id'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get extension informations #2'); - } - - $extension_row = DB()->sql_fetchrowset($result); - $num_extension_row = DB()->num_rows($result); - DB()->sql_freeresult($result); - - if ($num_extension_row > 0) { - $extension_row = sort_multi_array($extension_row, 'extension'); - - 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 { - $template->assign_block_vars('extension_row', array( - 'EXT_ID' => $extension_row[$i]['ext_id'], - 'EXTENSION' => $extension_row[$i]['extension'], - 'EXTENSION_EXPLAIN' => $extension_row[$i]['comment'], - 'S_GROUP_SELECT' => group_select('group_select[]', $extension_row[$i]['group_id'])) - ); - } - } - } -} - -// Extension 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('')); - $group_allowed_list = get_var('allowed_list', array(0)); - $download_mode_list = get_var('download_mode_list', array(0)); - $category_list = get_var('category_list', array(0)); - $upload_icon_list = get_var('upload_icon_list', array('')); - $filesize_list = get_var('max_filesize_list', array(0)); - $size_select_list = get_var('size_select_list', array('')); - - $allowed_list = array(); - - foreach ($group_allowed_list as $iValue) { - for ($j = 0, $jMax = count($group_change_list); $j < $jMax; $j++) { - if ($iValue == $group_change_list[$j]) { - $allowed_list[$j] = 1; - } - } - } - - for ($i = 0, $iMax = count($group_change_list); $i < $iMax; $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]); - - $sql_ary = array( - 'group_name' => (string)$extension_group_list[$i], - 'cat_id' => (int)$category_list[$i], - 'allow_group' => (int)$allowed, - 'download_mode' => (int)$download_mode_list[$i], - 'upload_icon' => (string)$upload_icon_list[$i], - 'max_filesize' => (int)$filesize_list[$i] - ); - - $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)) { - bb_die('Could not update extension groups informations'); - } - } - - // Delete Extension Groups - $group_id_list = get_var('group_id_list', array(0)); - - $group_id_sql = implode(', ', $group_id_list); - - if ($group_id_sql != '') { - $sql = 'DELETE - FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id IN (' . $group_id_sql . ')'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not delete extension groups'); - } - - // Set corresponding Extensions to a pending Group - $sql = 'UPDATE ' . BB_EXTENSIONS . ' - SET group_id = 0 - WHERE group_id IN (' . $group_id_sql . ')'; - - if (!$result = DB()->sql_query($sql)) { - bb_die('Could not assign extensions to pending group'); - } - } - - // Add Extensions? - $extension_group = get_var('add_extension_group', ''); - $download_mode = get_var('add_download_mode', 0); - $cat_id = get_var('add_category', 0); - $upload_icon = get_var('add_upload_icon', ''); - $filesize = get_var('add_max_filesize', 0); - $size_select = get_var('add_size_select', ''); - - $is_allowed = isset($_POST['add_allowed']) ? 1 : 0; - $add = isset($_POST['add_extension_group_check']) ? true : false; - - if ($extension_group != '' && $add) { - // check Extension Group - $sql = 'SELECT group_name FROM ' . BB_EXTENSION_GROUPS; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query extension groups table'); - } - - $row = DB()->sql_fetchrowset($result); - $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)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['EXTENSION_GROUP_EXIST'], $extension_group); - } - } - } - - if (!$error) { - $filesize = ($size_select == 'kb') ? round($filesize * 1024) : (($size_select == 'mb') ? round($filesize * 1048576) : $filesize); - - $sql_ary = array( - 'group_name' => (string)$extension_group, - 'cat_id' => (int)$cat_id, - 'allow_group' => (int)$is_allowed, - 'download_mode' => (int)$download_mode, - 'upload_icon' => (string)$upload_icon, - 'max_filesize' => (int)$filesize, - 'forum_permissions' => '' - ); - - $sql = 'INSERT INTO ' . BB_EXTENSION_GROUPS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary); - - if (!DB()->sql_query($sql)) { - bb_die('Could not add extension group'); - } - } - } - - if (!$error) { - bb_die($lang['ATTACH_CONFIG_UPDATED'] . '

' . sprintf($lang['CLICK_RETURN_ATTACH_CONFIG'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); - } -} - -if ($mode == 'groups') { - // Extension Groups - 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) { - $max_add_filesize = round($max_add_filesize / 1048576 * 100) / 100; - } elseif ($max_add_filesize >= 1024) { - $max_add_filesize = round($max_add_filesize / 1024 * 100) / 100; - } - - $viewgroup = get_var(POST_GROUPS_URL, 0); - - $template->assign_vars(array( - 'TPL_ATTACH_EXTENSION_GROUPS' => true, - 'ADD_GROUP_NAME' => $extension_group ?? '', - 'MAX_FILESIZE' => $max_add_filesize, - 'S_FILESIZE' => size_select('add_size_select', $size), - 'S_ADD_DOWNLOAD_MODE' => download_select('add_download_mode'), - 'S_SELECT_CAT' => category_select('add_category'), - 'S_CANCEL_ACTION' => 'admin_extensions.php?mode=groups', - 'S_ATTACH_ACTION' => 'admin_extensions.php?mode=groups', - )); - - $sql = 'SELECT * FROM ' . BB_EXTENSION_GROUPS; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get extension group informations'); - } - - $extension_group = DB()->sql_fetchrowset($result); - $num_extension_group = DB()->num_rows($result); - DB()->sql_freeresult($result); - - for ($i = 0; $i < $num_extension_group; $i++) { - // Format the 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) { - $extension_group[$i]['max_filesize'] = round($extension_group[$i]['max_filesize'] / 1048576 * 100) / 100; - } elseif ($extension_group[$i]['max_filesize'] >= 1024) { - $extension_group[$i]['max_filesize'] = round($extension_group[$i]['max_filesize'] / 1024 * 100) / 100; - } - - $s_allowed = ($extension_group[$i]['allow_group'] == 1) ? 'checked="checked"' : ''; - - $template->assign_block_vars('grouprow', array( - 'GROUP_ID' => $extension_group[$i]['group_id'], - 'EXTENSION_GROUP' => $extension_group[$i]['group_name'], - 'UPLOAD_ICON' => $extension_group[$i]['upload_icon'], - - 'S_ALLOW_SELECTED' => $s_allowed, - 'S_SELECT_CAT' => category_select('category_list[]', $extension_group[$i]['group_id']), - 'S_DOWNLOAD_MODE' => download_select('download_mode_list[]', $extension_group[$i]['group_id']), - 'S_FILESIZE' => size_select('size_select_list[]', $size_format), - - 'MAX_FILESIZE' => $extension_group[$i]['max_filesize'], - 'CAT_BOX' => ($viewgroup == $extension_group[$i]['group_id']) ? '-' : '+', - 'U_VIEWGROUP' => ($viewgroup == $extension_group[$i]['group_id']) ? 'admin_extensions.php?mode=groups' : 'admin_extensions.php?mode=groups&' . POST_GROUPS_URL . '=' . $extension_group[$i]['group_id'], - 'U_FORUM_PERMISSIONS' => "admin_extensions.php?mode=$mode&e_mode=perm&e_group=" . $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)) { - bb_die('Could not get extension informations #3'); - } - - $extension = DB()->sql_fetchrowset($result); - $num_extension = DB()->num_rows($result); - DB()->sql_freeresult($result); - - for ($j = 0; $j < $num_extension; $j++) { - $template->assign_block_vars('grouprow.extensionrow', array( - 'EXPLANATION' => $extension[$j]['comment'], - 'EXTENSION' => $extension[$j]['extension']) - ); - } - } - } -} - -if ($e_mode == 'perm') { - $group = get_var('e_group', 0); - - if (isset($_POST['close_perm'])) { - $e_mode = ''; - } -} - -// Add Forums -if ($add_forum && $e_mode == 'perm' && $group) { - $add_forums_list = get_var('entries', array(0)); - $add_all_forums = false; - - foreach ($add_forums_list as $iValue) { - if ($iValue == 0) { - $add_all_forums = true; - } - } - - // If we add ALL FORUMS, we are able to overwrite the Permissions - if ($add_all_forums) { - $sql = 'UPDATE ' . BB_EXTENSION_GROUPS . " SET forum_permissions = '' WHERE group_id = " . (int)$group; - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not update permissions #1'); - } - } - - // Else we have to add Permissions - if (!$add_all_forums) { - $sql = 'SELECT forum_permissions - FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id = ' . (int)$group . ' - LIMIT 1'; - - 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']) == '') { - $auth_p = array(); - } else { - $auth_p = auth_unpack($row['forum_permissions']); - } - - // Generate array for Auth_Pack, do not add doubled forums - foreach ($add_forums_list as $i => $iValue) { - if (!in_array($add_forums_list[$i], $auth_p)) { - $auth_p[] = $iValue; - } - } - - $auth_bitstream = auth_pack($auth_p); - - $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))) { - bb_die('Could not update permissions #2'); - } - } -} - -// Delete Forums -if ($delete_forum && $e_mode == 'perm' && $group) { - $delete_forums_list = get_var('entries', array(0)); - - // Get the current Forums - $sql = 'SELECT forum_permissions - FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id = ' . (int)$group . ' - LIMIT 1'; - - 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); - - $auth_p2 = auth_unpack(trim($row['forum_permissions'])); - $auth_p = array(); - - // Generate array for Auth_Pack, delete the chosen ones - foreach ($auth_p2 as $i => $iValue) { - if (!in_array($auth_p2[$i], $delete_forums_list)) { - $auth_p[] = $iValue; - } - } - - $auth_bitstream = (count($auth_p) > 0) ? auth_pack($auth_p) : ''; - - $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))) { - bb_die('Could not update permissions #3'); - } -} - -// Display the Group Permissions Box for configuring it -if ($e_mode == 'perm' && $group) { - $sql = 'SELECT group_name, forum_permissions - FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id = ' . (int)$group . ' - LIMIT 1'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get group name from ' . BB_EXTENSION_GROUPS); - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - - $group_name = $row['group_name']; - $allowed_forums = trim($row['forum_permissions']); - - $forum_perm = array(); - - if ($allowed_forums == '') { - $forum_perm[0]['forum_id'] = 0; - $forum_perm[0]['forum_name'] = $lang['PERM_ALL_FORUMS']; - } 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))) { - bb_die('Could not get forum names'); - } - - 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, $iMax = count($forum_perm); $i < $iMax; $i++) { - $template->assign_block_vars('allow_option_values', array( - 'VALUE' => $forum_perm[$i]['forum_id'], - 'OPTION' => htmlCHR($forum_perm[$i]['forum_name'])) - ); - } - - $template->assign_vars(array( - 'TPL_ATTACH_EXTENSION_GROUPS_PERMISSIONS' => true, - 'L_GROUP_PERMISSIONS_TITLE' => sprintf($lang['GROUP_PERMISSIONS_TITLE_ADMIN'], trim($group_name)), - 'A_PERM_ACTION' => "admin_extensions.php?mode=groups&e_mode=perm&e_group=$group", - )); - - $forum_option_values = array(0 => $lang['PERM_ALL_FORUMS']); - - $sql = 'SELECT forum_id, forum_name FROM ' . BB_FORUMS; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get forums #1'); - } - - while ($row = DB()->sql_fetchrow($result)) { - $forum_option_values[(int)$row['forum_id']] = $row['forum_name']; - } - DB()->sql_freeresult($result); - - foreach ($forum_option_values as $value => $option) { - $template->assign_block_vars('forum_option_values', array( - 'VALUE' => $value, - 'OPTION' => htmlCHR($option)) - ); - } - - $empty_perm_forums = array(); - - $sql = 'SELECT forum_id, forum_name FROM ' . BB_FORUMS . ' WHERE auth_attachments < ' . AUTH_ADMIN; - - if (!($f_result = DB()->sql_query($sql))) { - bb_die('Could not get forums #2'); - } - - while ($row = DB()->sql_fetchrow($f_result)) { - $forum_id = $row['forum_id']; - - $sql = 'SELECT forum_permissions - FROM ' . BB_EXTENSION_GROUPS . ' - WHERE allow_group = 1 - ORDER BY group_name ASC'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query extension groups'); - } - - $rows = DB()->sql_fetchrowset($result); - $num_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - - $found_forum = false; - - 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; - break; - } - } - - if (!$found_forum) { - $empty_perm_forums[$forum_id] = $row['forum_name']; - } - } - DB()->sql_freeresult($f_result); - - $message = ''; - - foreach ($empty_perm_forums as $forum_id => $forum_name) { - $message .= ($message == '') ? $forum_name : '
' . $forum_name; - } - - if (count($empty_perm_forums) > 0) { - $template->assign_vars(array('ERROR_MESSAGE' => $lang['NOTE_ADMIN_EMPTY_GROUP_PERMISSIONS'] . $message)); - } -} - -if ($error) { - $template->assign_vars(array('ERROR_MESSAGE' => $error_msg)); -} - -print_page('admin_extensions.tpl', 'admin'); diff --git a/admin/admin_groups.php b/admin/admin_groups.php index 13de0e024..d723b51e3 100644 --- a/admin/admin_groups.php +++ b/admin/admin_groups.php @@ -16,8 +16,6 @@ require __DIR__ . '/pagestart.php'; $group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : 0; $mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : ''; -attachment_quota_settings('group', isset($_POST['group_update']), $mode); - if (!empty($_POST['edit']) || !empty($_POST['new'])) { if (!empty($_POST['edit'])) { if (!$row = \TorrentPier\Legacy\Group::get_group_data($group_id)) { diff --git a/bt/announce.php b/bt/announce.php index af12ac322..359014539 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -282,7 +282,7 @@ $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 ($bb_cfg['tracker']['gold_silver_enabled'] && $down_add) { +if ($down_add) { if ($tor_type == TOR_TYPE_GOLD) { $down_add = 0; } // Silver releases diff --git a/common.php b/common.php index 1eae70686..0f2020269 100644 --- a/common.php +++ b/common.php @@ -81,7 +81,7 @@ define('FULL_URL', $server_protocol . $bb_cfg['server_name'] . $server_port . $b unset($server_protocol, $server_port); // Debug options -define('DBG_USER', (isset($_COOKIE[COOKIE_DBG]))); +define('DBG_USER', isset($_COOKIE[COOKIE_DBG])); // Board / tracker shared constants and functions define('BB_BT_TORRENTS', 'bb_bt_torrents'); @@ -428,7 +428,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true) } if (!empty($_POST) && $add_post) { - $str[] = "post: " . str_compact(urldecode(http_build_query($_POST))); + $str[] = 'Post: ' . str_compact(urldecode(http_build_query($_POST))); } $str = implode("\t", $str) . "\n"; bb_log($str, $file); diff --git a/dl_list.php b/dl_list.php index ee8d6d14a..e0f937f67 100644 --- a/dl_list.php +++ b/dl_list.php @@ -8,7 +8,6 @@ */ define('BB_SCRIPT', 'dl_list'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; $forum_id = isset($_REQUEST[POST_FORUM_URL]) ? (int)$_REQUEST[POST_FORUM_URL] : 0; diff --git a/feed.php b/feed.php index b5342d330..c73035565 100644 --- a/feed.php +++ b/feed.php @@ -8,10 +8,9 @@ */ define('BB_SCRIPT', 'feed'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; -$user->session_start(array('req_login' => true)); +$user->session_start(['req_login' => true]); $mode = $_REQUEST['mode'] ?? ''; $type = $_POST['type'] ?? ''; diff --git a/group.php b/group.php index 8c014ac37..65e70bff7 100644 --- a/group.php +++ b/group.php @@ -8,7 +8,6 @@ */ define('BB_SCRIPT', 'group'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; require INC_DIR . '/bbcode.php'; diff --git a/group_edit.php b/group_edit.php index b94e779a7..893d0dbf1 100644 --- a/group_edit.php +++ b/group_edit.php @@ -8,7 +8,6 @@ */ define('BB_SCRIPT', 'group_edit'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; $page_cfg['include_bbcode_js'] = true; @@ -38,13 +37,13 @@ if ($is_moderator) { if (!empty($_FILES['avatar']['name']) && $bb_cfg['group_avatars']['up_allowed']) { $upload = new TorrentPier\Legacy\Common\Upload(); - 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']) && $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id']))) { $avatar_ext_id = (int)$upload->file_ext_id; } else { bb_die(implode($upload->errors)); } - DB()->query("UPDATE " . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id"); + DB()->query("UPDATE " . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id LIMIT 1"); } } diff --git a/index.php b/index.php index 1d4382707..14419d6ec 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,6 @@ */ define('BB_SCRIPT', 'index'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; $page_cfg['load_tpl_vars'] = array( diff --git a/info.php b/info.php index 12a10476b..16fccf236 100644 --- a/info.php +++ b/info.php @@ -8,7 +8,6 @@ */ define('BB_SCRIPT', 'info'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; // Start session management diff --git a/library/ajax/avatar.php b/library/ajax/avatar.php index 6649f98dc..79364753b 100644 --- a/library/ajax/avatar.php +++ b/library/ajax/avatar.php @@ -16,7 +16,7 @@ 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 || !($u_data = get_userdata($user_id))) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } @@ -36,7 +36,7 @@ switch ($mode) { $this->ajax_die('Invalid mode'); } -DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = $new_ext_id WHERE user_id = $user_id"); +DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = $new_ext_id WHERE user_id = $user_id LIMIT 1"); \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id); diff --git a/library/ajax/change_user_opt.php b/library/ajax/change_user_opt.php index 0417f9ca6..e5e872331 100644 --- a/library/ajax/change_user_opt.php +++ b/library/ajax/change_user_opt.php @@ -16,7 +16,7 @@ global $bf, $lang; $user_id = (int)$this->request['user_id']; $new_opt = json_decode($this->request['user_opt'], true, 512, JSON_THROW_ON_ERROR); -if (!$user_id or !$u_data = get_userdata($user_id)) { +if (!$user_id || !($u_data = get_userdata($user_id))) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } @@ -30,7 +30,7 @@ foreach ($bf['user_opt'] as $opt_name => $opt_bit) { } } -DB()->query("UPDATE " . BB_USERS . " SET user_opt = {$u_data['user_opt']} WHERE user_id = $user_id"); +DB()->query("UPDATE " . BB_USERS . " SET user_opt = {$u_data['user_opt']} WHERE user_id = $user_id LIMIT 1"); // Удаляем данные из кеша \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id); diff --git a/library/ajax/change_user_rank.php b/library/ajax/change_user_rank.php index 0397cfef7..65e896251 100644 --- a/library/ajax/change_user_rank.php +++ b/library/ajax/change_user_rank.php @@ -16,7 +16,7 @@ global $datastore, $lang; $ranks = $datastore->get('ranks'); $rank_id = (int)$this->request['rank_id']; -if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) { +if (!($user_id = (int)$this->request['user_id']) || !($profiledata = get_userdata($user_id))) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } @@ -24,7 +24,7 @@ if ($rank_id != 0 && !isset($ranks[$rank_id])) { $this->ajax_die("invalid rank_id: $rank_id"); } -DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id"); +DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id LIMIT 1"); \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id); diff --git a/library/ajax/edit_group_profile.php b/library/ajax/edit_group_profile.php index 36abc022e..0b7394d5a 100644 --- a/library/ajax/edit_group_profile.php +++ b/library/ajax/edit_group_profile.php @@ -13,7 +13,7 @@ if (!defined('IN_AJAX')) { global $bb_cfg, $userdata, $lang; -if (!$group_id = (int)$this->request['group_id'] or !$group_info = \TorrentPier\Legacy\Group::get_group_data($group_id)) { +if (!($group_id = (int)$this->request['group_id']) || !($group_info = \TorrentPier\Legacy\Group::get_group_data($group_id))) { $this->ajax_die($lang['NO_GROUP_ID_SPECIFIED']); } if (!$mode = (string)$this->request['mode']) { @@ -51,4 +51,4 @@ switch ($mode) { } $value_sql = DB()->escape($value, true); -DB()->query("UPDATE " . BB_GROUPS . " SET $mode = $value_sql WHERE group_id = $group_id"); +DB()->query("UPDATE " . BB_GROUPS . " SET $mode = $value_sql WHERE group_id = $group_id LIMIT 1"); diff --git a/library/ajax/edit_user_profile.php b/library/ajax/edit_user_profile.php index 859838c74..437e467be 100644 --- a/library/ajax/edit_user_profile.php +++ b/library/ajax/edit_user_profile.php @@ -13,7 +13,7 @@ if (!defined('IN_AJAX')) { global $bb_cfg, $lang; -if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) { +if (!($user_id = (int)$this->request['user_id']) || !($profiledata = get_userdata($user_id))) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } if (!$field = (string)$this->request['field']) { @@ -109,7 +109,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']) || ($value > TIMENOW)) { $this->ajax_die($lang['INVALID_DATE'] . $this->request['value']); } $this->response['new_value'] = bb_date($value, 'Y-m-d H:i', false); @@ -151,7 +151,7 @@ switch ($field) { } $value_sql = DB()->escape($value, true); -DB()->query("UPDATE $table SET $field = $value_sql WHERE user_id = $user_id"); +DB()->query("UPDATE $table SET $field = $value_sql WHERE user_id = $user_id LIMIT 1"); \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($user_id); diff --git a/library/ajax/group_membership.php b/library/ajax/group_membership.php index 2979a2dbd..5aeb4852f 100644 --- a/library/ajax/group_membership.php +++ b/library/ajax/group_membership.php @@ -13,7 +13,7 @@ if (!defined('IN_AJAX')) { global $lang, $user; -if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) { +if (!($user_id = (int)$this->request['user_id']) || !($profiledata = get_userdata($user_id))) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } diff --git a/library/ajax/index_data.php b/library/ajax/index_data.php index 2395718a8..d40e98f9b 100644 --- a/library/ajax/index_data.php +++ b/library/ajax/index_data.php @@ -73,7 +73,7 @@ switch ($mode) { } $html = ': '; - $html .= ($moderators) ? implode(', ', $moderators) : $lang['NONE']; + $html .= $moderators ? implode(', ', $moderators) : $lang['NONE']; unset($moderators, $mod); $datastore->rm('moderators'); break; @@ -88,7 +88,7 @@ switch ($mode) { } 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']); + DB()->query('UPDATE ' . BB_USERS . " SET user_timezone = $tz WHERE user_id = " . $userdata['user_id'] . ' LIMIT 1'); $bb_cfg['board_timezone'] = $tz; \TorrentPier\Legacy\Sessions::cache_rm_user_sessions($userdata['user_id']); } @@ -110,7 +110,7 @@ switch ($mode) { ' . $lang['UPLOADED'] . ' ' . $lang['RELEASED'] . ' ' . $lang['BONUS'] . ''; - $html .= ($bb_cfg['seed_bonus_enabled']) ? '' . $lang['SEED_BONUS'] . '' : ''; + $html .= $bb_cfg['seed_bonus_enabled'] ? '' . $lang['SEED_BONUS'] . '' : ''; $html .= ' ' . $lang['TOTAL_TRAF'] . ' @@ -118,13 +118,13 @@ switch ($mode) { ' . humn_size($btu['u_up_total']) . ' ' . humn_size($btu['u_up_release']) . ' ' . humn_size($btu['u_up_bonus']) . ''; - $html .= ($bb_cfg['seed_bonus_enabled']) ? '' . $profiledata['user_points'] . '' : ''; + $html .= $bb_cfg['seed_bonus_enabled'] ? '' . $profiledata['user_points'] . '' : ''; $html .= ' ' . $lang['MAX_SPEED'] . ' ' . $lang['DL_DL_SPEED'] . ': ' . $speed_down . ' ' . $lang['DL_UL_SPEED'] . ': ' . $speed_up . ''; - $html .= ($bb_cfg['seed_bonus_enabled']) ? '' : ''; + $html .= $bb_cfg['seed_bonus_enabled'] ? '' : ''; $html .= ''; $this->response['user_ratio'] = ' diff --git a/library/ajax/topic_tpl.php b/library/ajax/topic_tpl.php index 5f683781e..d031d0457 100644 --- a/library/ajax/topic_tpl.php +++ b/library/ajax/topic_tpl.php @@ -115,7 +115,7 @@ switch ($mode) { $new_tpl_id = $tpl_id; $this->response['msg'] = "Включен шаблон $tpl_name"; } - DB()->query("UPDATE " . BB_FORUMS . " SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id"); + DB()->query("UPDATE " . BB_FORUMS . " SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id LIMIT 1"); break; // сохранение изменений @@ -126,8 +126,8 @@ switch ($mode) { $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"; - if (!@DB()->query($sql)) { + $sql = "UPDATE " . BB_TOPIC_TPL . " SET " . DB()->build_array('UPDATE', $sql_args) . " WHERE tpl_id = $tpl_id LIMIT 1"; + if (!DB()->query($sql)) { $sql_error = DB()->sql_error(); } $this->response['tpl_id'] = $tpl_id; @@ -139,7 +139,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; diff --git a/library/ajax/view_post.php b/library/ajax/view_post.php index 496a26252..b26ee3a65 100644 --- a/library/ajax/view_post.php +++ b/library/ajax/view_post.php @@ -13,8 +13,8 @@ if (!defined('IN_AJAX')) { global $user, $lang; -$post_id = (int)@$this->request['post_id']; -$topic_id = (int)@$this->request['topic_id']; +$post_id = (int)$this->request['post_id']; +$topic_id = (int)$this->request['topic_id']; if (!$post_id) { $post_id = DB()->fetch_row("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id", 'topic_first_post_id'); diff --git a/library/attach_mod/.htaccess b/library/attach_mod/.htaccess deleted file mode 100644 index b66e80882..000000000 --- a/library/attach_mod/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Require all denied diff --git a/library/attach_mod/attachment_mod.php b/library/attach_mod/attachment_mod.php deleted file mode 100644 index 004604c90..000000000 --- a/library/attach_mod/attachment_mod.php +++ /dev/null @@ -1,80 +0,0 @@ -sql_query($sql))) { - bb_die('Could not query attachment information'); - } - - while ($row = DB()->sql_fetchrow($result)) { - $attach_config[$row['config_name']] = trim($row['config_value']); - } - - // We assign the original default board language here, because it gets overwritten later with the users default language - $attach_config['board_lang'] = trim($bb_cfg['default_lang']); - - return $attach_config; -} - -// Get Attachment Config -$attach_config = array(); - -if (!$attach_config = CACHE('bb_cache')->get('attach_config')) { - $attach_config = get_config(); - CACHE('bb_cache')->set('attach_config', $attach_config, 86400); -} - -include ATTACH_DIR . '/displaying.php'; -include ATTACH_DIR . '/posting_attachments.php'; - -$upload_dir = $attach_config['upload_dir']; diff --git a/library/attach_mod/displaying.php b/library/attach_mod/displaying.php deleted file mode 100644 index 012bac2b6..000000000 --- a/library/attach_mod/displaying.php +++ /dev/null @@ -1,306 +0,0 @@ -update('attach_extensions'); - $extension_informations = get_extension_informations(); - } - $allowed_extensions = array(); - - for ($i = 0, $size = count($extension_informations); $i < $size; $i++) { - $extension = strtolower(trim($extension_informations[$i]['extension'])); - $allowed_extensions[] = $extension; - $display_categories[$extension] = (int)$extension_informations[$i]['cat_id']; - $download_modes[$extension] = (int)$extension_informations[$i]['download_mode']; - $upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']); - } -} - -/** - * Writing Data into plain Template Vars - */ -function init_display_template($template_var, $replacement, $filename = 'viewtopic_attach.tpl') -{ - global $template; - - // This function is adapted from the old template class - // I wish i had the functions from the 3.x one. :D (This class rocks, can't await to use it in Mods) - - // Handle Attachment Informations - if (!isset($template->uncompiled_code[$template_var]) && empty($template->uncompiled_code[$template_var])) { - // If we don't have a file assigned to this handle, die. - if (!isset($template->files[$template_var])) { - die("Template->loadfile(): No file specified for handle $template_var"); - } - - $filename_2 = $template->files[$template_var]; - - $str = file_get_contents($filename_2); - if (empty($str)) { - die("Template->loadfile(): File $filename_2 for handle $template_var is empty"); - } - - $template->uncompiled_code[$template_var] = $str; - } - - $complete_filename = $filename; - if ($complete_filename[0] != '/') { - $complete_filename = $template->root . '/' . $complete_filename; - } - - if (!file_exists($complete_filename)) { - die("Template->make_filename(): Error - file $complete_filename does not exist"); - } - - $content = file_get_contents($complete_filename); - if (empty($content)) { - die('Template->loadfile(): File ' . $complete_filename . ' is empty'); - } - - // replace $replacement with uncompiled code in $filename - $template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]); -} - -/** - * Display Attachments in Posts - */ -function display_post_attachments($post_id, $switch_attachment) -{ - global $attach_config, $is_auth; - - if ((int)$switch_attachment == 0 || (int)$attach_config['disable_mod']) { - return; - } - - if ($is_auth['auth_download'] && $is_auth['auth_view']) { - display_attachments($post_id); - } -} - -/** - * Initializes some templating variables for displaying Attachments in Posts - */ -function init_display_post_attachments($switch_attachment) -{ - global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data; - - if (empty($t_data) && !empty($forum_row)) { - $switch_attachment = $forum_row['topic_attachment']; - } - - if ((int)$switch_attachment == 0 || (int)$attach_config['disable_mod'] || (!($is_auth['auth_download'] && $is_auth['auth_view']))) { - init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl'); - return; - } - - $post_id_array = array(); - - for ($i = 0; $i < $total_posts; $i++) { - if ($postrow[$i]['post_attachment'] == 1) { - $post_id_array[] = (int)$postrow[$i]['post_id']; - } - } - - if (count($post_id_array) == 0) { - return; - } - - $rows = get_attachments_from_post($post_id_array); - $num_rows = count($rows); - - if ($num_rows == 0) { - return; - } - - @reset($attachments); - - for ($i = 0; $i < $num_rows; $i++) { - $attachments['_' . $rows[$i]['post_id']][] = $rows[$i]; - //bt - if ($rows[$i]['tracker_status']) { - if (defined('TORRENT_POST')) { - bb_die('Multiple registered torrents in one topic

first torrent found in post_id = ' . TORRENT_POST . '
current post_id = ' . $rows[$i]['post_id'] . '

attachments info:
' . print_r($rows, true) . '
'); - } - define('TORRENT_POST', $rows[$i]['post_id']); - } - //bt end - } - - init_display_template('body', '{postrow.ATTACHMENTS}'); - - init_complete_extensions_data(); -} - -/** - * END ATTACHMENT DISPLAY IN POSTS - */ - -/** - * Assign Variables and Definitions based on the fetched Attachments - internal - * used by all displaying functions, the Data was collected before, it's only dependend on the template used. :) - * before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...) - */ -function display_attachments($post_id) -{ - global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config; - - $num_attachments = @count($attachments['_' . $post_id]); - - if ($num_attachments == 0) { - return; - } - - $template->assign_block_vars('postrow.attach', array()); - - for ($i = 0; $i < $num_attachments; $i++) { - // Some basic things... - $filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']); - $thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']); - - $upload_image = ''; - - if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']])) { - $upload_image = ''; - } elseif (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '') { - $upload_image = ''; - } - - $filesize = humn_size($attachments['_' . $post_id][$i]['filesize']); - - $display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']); - $comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']); - $comment = str_replace("\n", '
', $comment); - - $denied = false; - - // Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin - if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) { - $denied = true; - - $template->assign_block_vars('postrow.attach.denyrow', array( - 'L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension'])) - ); - } - - if (!$denied || IS_ADMIN) { - // define category - $image = false; - $thumbnail = false; - $link = false; - - if (@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT && (int)$attach_config['img_display_inlined']) { - if ((int)$attach_config['img_link_width'] != 0 || (int)$attach_config['img_link_height'] != 0) { - [$width, $height] = image_getdimension($filename); - - if ($width == 0 && $height == 0) { - $image = true; - } else { - if ($width <= (int)$attach_config['img_link_width'] && $height <= (int)$attach_config['img_link_height']) { - $image = true; - } - } - } else { - $image = true; - } - } - - if (@(int)$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) { - // Images - if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) { - $img_source = BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id']; - $download_link = true; - } else { - $img_source = $filename; - $download_link = false; - } - - $template->assign_block_vars('postrow.attach.cat_images', array( - 'DOWNLOAD_NAME' => $display_name, - 'S_UPLOAD_IMAGE' => $upload_image, - 'IMG_SRC' => $img_source, - 'FILESIZE' => $filesize, - 'COMMENT' => $comment, - )); - - // Directly Viewed Image ... update the download count - if (!$download_link) { - $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' - SET download_count = download_count + 1 - WHERE attach_id = ' . (int)$attachments['_' . $post_id][$i]['attach_id']; - - if (!(DB()->sql_query($sql))) { - bb_die('Could not update attachment download count'); - } - } - } - - if ($thumbnail) { - // Images, but display Thumbnail - if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) { - $thumb_source = BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1'; - } else { - $thumb_source = $thumbnail_filename; - } - - $template->assign_block_vars('postrow.attach.cat_thumb_images', array( - 'DOWNLOAD_NAME' => $display_name, - 'S_UPLOAD_IMAGE' => $upload_image, - 'IMG_SRC' => BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id'], - 'IMG_THUMB_SRC' => $thumb_source, - 'FILESIZE' => $filesize, - 'COMMENT' => $comment, - )); - } - - // bt - if ($link && ($attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT)) { - include ATTACH_DIR . '/displaying_torrent.php'; - } elseif ($link) { - $target_blank = ((@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT)) ? 'target="_blank"' : ''; - - // display attachment - $template->assign_block_vars('postrow.attach.attachrow', array( - 'U_DOWNLOAD_LINK' => BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id'], - 'S_UPLOAD_IMAGE' => $upload_image, - 'DOWNLOAD_NAME' => $display_name, - 'FILESIZE' => $filesize, - 'COMMENT' => $comment, - 'TARGET_BLANK' => $target_blank, - 'DOWNLOAD_COUNT' => declension((int)$attachments['_' . $post_id][$i]['download_count'], 'times'), - )); - } - } - } -} diff --git a/library/attach_mod/includes/functions_admin.php b/library/attach_mod/includes/functions_admin.php deleted file mode 100644 index 01781a3ce..000000000 --- a/library/attach_mod/includes/functions_admin.php +++ /dev/null @@ -1,269 +0,0 @@ -sql_query($sql)) { - bb_die('Could not get entry #1'); - } - - if (DB()->num_rows($result) == 0) { - $sql_ary = [ - 'user_id' => (int)$id, - 'group_id' => 0, - 'quota_type' => (int)$quota_type, - 'quota_limit_id' => (int)$quota_limit_id - ]; - $sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary); - } else { - $sql = 'UPDATE ' . BB_QUOTA . " - SET quota_limit_id = $quota_limit_id - WHERE user_id = $id - AND quota_type = $quota_type"; - } - DB()->sql_freeresult($result); - } - - if (!($result = DB()->sql_query($sql))) { - bb_die('Unable to update quota settings'); - } - } elseif ($mode == 'group') { - if (!$quota_limit_id) { - $sql = 'DELETE FROM ' . BB_QUOTA . " WHERE group_id = $id AND quota_type = $quota_type"; - if (!$result = DB()->sql_query($sql)) { - bb_die('Unable to delete quota settings'); - } - } else { - // Check if user is already entered - $sql = 'SELECT group_id FROM ' . BB_QUOTA . " WHERE group_id = $id AND quota_type = $quota_type"; - if (!$result = DB()->sql_query($sql)) { - bb_die('Could not get entry #2'); - } - - if (DB()->num_rows($result) == 0) { - $sql = 'INSERT INTO ' . BB_QUOTA . " (user_id, group_id, quota_type, quota_limit_id) - VALUES (0, $id, $quota_type, $quota_limit_id)"; - } else { - $sql = 'UPDATE ' . BB_QUOTA . " SET quota_limit_id = $quota_limit_id - WHERE group_id = $id AND quota_type = $quota_type"; - } - - if (!DB()->sql_query($sql)) { - bb_die('Unable to update quota settings'); - } - } - } -} - -/** - * Sort multi-dimensional array - * - * @param array $sort_array - * @param string|int $key - * @param int $sort_order - * @return array - */ -function sort_multi_array(array $sort_array, $key, int $sort_order = SORT_ASC): array -{ - $keys = array_column($sort_array, $key); - array_multisort($keys, $sort_order, $sort_array); - - return $sort_array; -} - -/** - * Returns size of the upload directory in human readable format - * - * @return string - */ -function get_formatted_dirsize() -{ - global $lang, $upload_dir; - - $upload_dir_size = 0; - - if ($dirname = opendir($upload_dir)) { - while ($file = readdir($dirname)) { - if ( - $file != 'index.php' && - $file != '.htaccess' && - !is_dir($upload_dir . '/' . $file) && - !is_link($upload_dir . '/' . $file) - ) { - $upload_dir_size += filesize($upload_dir . '/' . $file); - } - } - closedir($dirname); - } else { - return $lang['NOT_AVAILABLE']; - } - - return humn_size($upload_dir_size); -} - -/** - * Build SQL statement for the search feature - * - * @param $order_by - * @param $total_rows - * @return array - */ -function search_attachments($order_by, &$total_rows) -{ - global $lang; - - $where_sql = []; - - // Author name search - $search_author = get_var('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)); - - // Prepare for directly going into sql query - $search_author = str_replace('*', '%', attach_mod_sql_escape($search_author)); - - // We need the post_id's, because we want to query the Attachment Table - $sql = 'SELECT user_id FROM ' . BB_USERS . " WHERE username LIKE '$search_author'"; - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not obtain list of matching users (searching for: ' . $search_author . ')'); - } - - $matching_userids = ''; - if ($row = DB()->sql_fetchrow($result)) { - do { - $matching_userids .= (($matching_userids != '') ? ', ' : '') . $row['user_id']; - } while ($row = DB()->sql_fetchrow($result)); - - DB()->sql_freeresult($result); - } else { - bb_die($lang['NO_ATTACH_SEARCH_MATCH']); - } - - $where_sql[] = ' (t.user_id_1 IN (' . $matching_userids . ')) '; - } - - // Search Keyword - $search_keyword_fname = get_var('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) . "') "; - } - - $search_keyword_comment = get_var('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 - $search_count_smaller = get_var('search_count_smaller', ''); - $search_count_greater = get_var('search_count_greater', ''); - if ($search_count_smaller != '') { - $where_sql[] = ' (a.download_count < ' . (int)$search_count_smaller . ') '; - } elseif ($search_count_greater != '') { - $where_sql[] = ' (a.download_count > ' . (int)$search_count_greater . ') '; - } - - // Search Filesize - $search_size_smaller = get_var('search_size_smaller', ''); - $search_size_greater = get_var('search_size_greater', ''); - if ($search_size_smaller != '') { - $where_sql[] = ' (a.filesize < ' . (int)$search_size_smaller . ') '; - } elseif ($search_size_greater != '') { - $where_sql[] = ' (a.filesize > ' . (int)$search_size_greater . ') '; - } - - // Search Attachment Time - $search_days_greater = get_var('search_days_greater', ''); - if ($search_days_greater) { - $where_sql[] = ' (a.filetime < ' . (TIMENOW - ((int)$search_days_greater * 86400)) . ') '; - } - - // Search Forum - $search_forum = get_var('search_forum', ''); - if ($search_forum) { - $where_sql[] = ' (p.forum_id = ' . (int)$search_forum . ') '; - } - - $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 (count($where_sql) > 0) { - $sql .= implode('AND', $where_sql) . ' AND '; - } - - $sql .= 't.post_id = p.post_id AND a.attach_id = t.attach_id '; - - $total_rows_sql = $sql; - - $sql .= $order_by; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query attachments #1'); - } - - $attachments = DB()->sql_fetchrowset($result); - $num_attach = DB()->num_rows($result); - DB()->sql_freeresult($result); - - if ($num_attach == 0) { - bb_die($lang['NO_ATTACH_SEARCH_MATCH']); - } - - if (!($result = DB()->sql_query($total_rows_sql))) { - bb_die('Could not query attachments #2'); - } - - $total_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - - return $attachments; -} - -/** - * Perform limit statement on arrays - * - * @param $array - * @param $start - * @param $pagelimit - * @return array - */ -function limit_array($array, $start, $pagelimit) -{ - // array from start - start+pagelimit - $limit = (count($array) < ($start + $pagelimit)) ? count($array) : $start + $pagelimit; - - $limit_array = []; - - for ($i = $start; $i < $limit; $i++) { - $limit_array[] = $array[$i]; - } - - return $limit_array; -} diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php deleted file mode 100644 index 6b978af24..000000000 --- a/library/attach_mod/includes/functions_attach.php +++ /dev/null @@ -1,592 +0,0 @@ - 4096) { - return; - } - - if ($number < $base) { - return $chars[$number]; - } - - $hexval = ''; - - while ($number > 0) { - $remainder = $number % $base; - - if ($remainder < $base) { - $hexval = $chars[$remainder] . $hexval; - } - - $number = floor($number / $base); - } - - return $hexval; -} - -/** - * base64todec function - */ -function base64_unpack($string) -{ - $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-'; - $base = strlen($chars); - - $length = strlen($string); - $number = 0; - - for ($i = 1; $i <= $length; $i++) { - $pos = $length - $i; - $operand = strpos($chars, (string) $string[$pos]); - $exponent = $base ** ($i - 1); - $decValue = $operand * $exponent; - $number += $decValue; - } - - return $number; -} - -/** - * Per Forum based Extension Group Permissions (Encode Number) -> Theoretically up to 158 Forums saveable. :) - * We are using a base of 64, but splitting it to one-char and two-char numbers. :) - */ -function auth_pack($auth_array) -{ - $one_char_encoding = '#'; - $two_char_encoding = '.'; - $one_char = $two_char = false; - $auth_cache = ''; - - foreach ($auth_array as $i => $iValue) { - $val = base64_pack((int)$auth_array[$i]); - if (strlen($val) == 1 && !$one_char) { - $auth_cache .= $one_char_encoding; - $one_char = true; - } elseif (strlen($val) == 2 && !$two_char) { - $auth_cache .= $two_char_encoding; - $two_char = true; - } - - $auth_cache .= $val; - } - - return $auth_cache; -} - -/** - * Reverse the auth_pack process - */ -function auth_unpack($auth_cache) -{ - $one_char_encoding = '#'; - $two_char_encoding = '.'; - - $auth = []; - $auth_len = 1; - - for ($pos = 0, $posMax = strlen($auth_cache); $pos < $posMax; $pos += $auth_len) { - $forum_auth = $auth_cache[$pos]; - if ($forum_auth == $one_char_encoding) { - $auth_len = 1; - continue; - } - - if ($forum_auth == $two_char_encoding) { - $auth_len = 2; - $pos--; - continue; - } - - $forum_auth = substr($auth_cache, $pos, $auth_len); - $forum_id = base64_unpack($forum_auth); - $auth[] = (int)$forum_id; - } - return $auth; -} - -/** - * Used for determining if Forum ID is authed, please use this Function on all Posting Screens - */ -function is_forum_authed($auth_cache, $check_forum_id) -{ - $one_char_encoding = '#'; - $two_char_encoding = '.'; - - if (trim($auth_cache) == '') { - return true; - } - - $auth = []; - $auth_len = 1; - - for ($pos = 0, $posMax = strlen($auth_cache); $pos < $posMax; $pos += $auth_len) { - $forum_auth = $auth_cache[$pos]; - if ($forum_auth == $one_char_encoding) { - $auth_len = 1; - continue; - } - - if ($forum_auth == $two_char_encoding) { - $auth_len = 2; - $pos--; - continue; - } - - $forum_auth = substr($auth_cache, $pos, $auth_len); - $forum_id = (int)base64_unpack($forum_auth); - if ($forum_id == $check_forum_id) { - return true; - } - } - return false; -} - -/** - * Deletes an Attachment - */ -function unlink_attach($filename, $mode = false) -{ - global $upload_dir, $attach_config; - - $filename = basename($filename); - - if ($mode == MODE_THUMBNAIL) { - $filename = $upload_dir . '/' . THUMB_DIR . '/t_' . $filename; - } else { - $filename = $upload_dir . '/' . $filename; - } - - return @unlink($filename); -} - -/** - * Check if Attachment exist - */ -function attachment_exists($filename) -{ - global $upload_dir, $attach_config; - - $filename = basename($filename); - - if (!@file_exists(@amod_realpath($upload_dir . '/' . $filename))) { - return false; - } - - return true; -} - -/** - * Check if Thumbnail exist - */ -function thumbnail_exists($filename) -{ - global $upload_dir, $attach_config; - - $filename = basename($filename); - - if (!@file_exists(@amod_realpath($upload_dir . '/' . THUMB_DIR . '/t_' . $filename))) { - return false; - } - - return true; -} - -/** - * Physical Filename stored already ? - */ -function physical_filename_already_stored($filename) -{ - if ($filename == '') { - return false; - } - - $filename = basename($filename); - - $sql = 'SELECT attach_id - FROM ' . BB_ATTACHMENTS_DESC . " - WHERE physical_filename = '" . attach_mod_sql_escape($filename) . "' - LIMIT 1"; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get attachment information for filename: ' . htmlspecialchars($filename)); - } - $num_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - - return $num_rows != 0; -} - -/** - * get all attachments from a post (could be an post array too) - */ -function get_attachments_from_post($post_id_array) -{ - global $attach_config; - - $attachments = []; - - if (!is_array($post_id_array)) { - if (empty($post_id_array)) { - return $attachments; - } - - $post_id = (int)$post_id_array; - - $post_id_array = []; - $post_id_array[] = $post_id; - } - - $post_id_array = implode(', ', array_map('\intval', $post_id_array)); - - if ($post_id_array == '') { - return $attachments; - } - - $display_order = ((int)$attach_config['display_order'] == 0) ? 'DESC' : 'ASC'; - - $sql = 'SELECT a.post_id, d.* - FROM ' . BB_ATTACHMENTS . ' a, ' . BB_ATTACHMENTS_DESC . " d - WHERE a.post_id IN ($post_id_array) - AND a.attach_id = d.attach_id - ORDER BY d.filetime $display_order"; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get attachment informations for post number ' . $post_id_array); - } - - $num_rows = DB()->num_rows($result); - $attachments = DB()->sql_fetchrowset($result); - DB()->sql_freeresult($result); - - if ($num_rows == 0) { - return []; - } - - return $attachments; -} - -/** - * Count Filesize of Attachments in Database based on the attachment id - */ -function get_total_attach_filesize($attach_ids) -{ - if (!is_array($attach_ids) || !count($attach_ids)) { - return 0; - } - - $attach_ids = implode(', ', array_map('\intval', $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))) { - bb_die('Could not query total filesize'); - } - - $total_filesize = 0; - - while ($row = DB()->sql_fetchrow($result)) { - $total_filesize += (int)$row['filesize']; - } - DB()->sql_freeresult($result); - - return $total_filesize; -} - -/** - * Get allowed Extensions and their respective Values - */ -function get_extension_informations() -{ - return $GLOBALS['datastore']->get('attach_extensions'); -} - -// -// Sync Topic -// -function attachment_sync_topic($topics) -{ - if (is_array($topics)) { - $topics = implode(',', $topics); - } - $posts_without_attach = $topics_without_attach = []; - - // Check orphan post_attachment markers - $sql = "SELECT p.post_id - FROM " . BB_POSTS . " p - LEFT JOIN " . BB_ATTACHMENTS . " a USING(post_id) - WHERE p.topic_id IN($topics) - AND p.post_attachment = 1 - AND a.post_id IS NULL"; - - if ($rowset = DB()->fetch_rowset($sql)) { - foreach ($rowset as $row) { - $posts_without_attach[] = $row['post_id']; - } - if ($posts_sql = implode(',', $posts_without_attach)) { - DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)"); - } - } - - // Update missing topic_attachment markers - DB()->query(" - UPDATE " . BB_TOPICS . " t, " . BB_POSTS . " p SET - t.topic_attachment = 1 - WHERE p.topic_id IN($topics) - AND p.post_attachment = 1 - AND p.topic_id = t.topic_id - "); - - // Fix orphan topic_attachment markers - $sql = "SELECT t.topic_id - FROM " . BB_POSTS . " p, " . BB_TOPICS . " t - WHERE t.topic_id = p.topic_id - AND t.topic_id IN($topics) - AND t.topic_attachment = 1 - GROUP BY p.topic_id - HAVING SUM(p.post_attachment) = 0"; - - if ($rowset = DB()->fetch_rowset($sql)) { - foreach ($rowset as $row) { - $topics_without_attach[] = $row['topic_id']; - } - if ($topics_sql = implode(',', $topics_without_attach)) { - DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)"); - } - } -} - -/** - * Get Extension - */ -function get_extension($filename) -{ - if (false === strpos($filename, '.')) { - return ''; - } - $extension = strrchr(strtolower($filename), '.'); - $extension[0] = ' '; - $extension = strtolower(trim($extension)); - if (is_array($extension)) { - return ''; - } - - return $extension; -} - -/** - * Delete Extension - */ -function delete_extension($filename) -{ - return substr($filename, 0, strripos(trim($filename), '.')); -} - -/** - * Check if a user is within Group - */ -function user_in_group($user_id, $group_id) -{ - $user_id = (int)$user_id; - $group_id = (int)$group_id; - - if (!$user_id || !$group_id) { - return false; - } - - $sql = 'SELECT u.group_id - FROM ' . BB_USER_GROUP . ' u, ' . BB_GROUPS . " g - WHERE g.group_single_user = 0 - AND u.group_id = g.group_id - AND u.user_id = $user_id - AND g.group_id = $group_id - LIMIT 1"; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get user group'); - } - - $num_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - - return !($num_rows == 0); -} - -/** - * Realpath replacement for attachment mod - */ -function amod_realpath($path) -{ - return (function_exists('realpath')) ? realpath($path) : $path; -} - -/** - * _set_var - * - * Set variable, used by {@link get_var the get_var function} - * - * @private - */ -function _set_var(&$result, $var, $type, $multibyte = false) -{ - settype($var, $type); - $result = $var; - - 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) { - $result = preg_replace('#&(\#[0-9]+;)#', '&\1', $result); - } - } -} - -/** - * Used to get passed variable - * - * @param $var_name - * @param $default - * @param bool $multibyte - * @return array - */ -function get_var($var_name, $default, $multibyte = false) -{ - $type = null; - if (!isset($_REQUEST[$var_name]) || - (is_array($_REQUEST[$var_name]) && !is_array($default)) || - (is_array($default) && !is_array($_REQUEST[$var_name]))) { - return (is_array($default)) ? [] : $default; - } - - $var = $_REQUEST[$var_name]; - - if (!is_array($default)) { - $type = gettype($default); - $key_type = null; - } else { - foreach ($default as $key_type => $type) { - $key_type = gettype($key_type); - $type = gettype($type); - } - } - - if (is_array($var)) { - $_var = $var; - $var = []; - - 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 { - _set_var($k, $k, $key_type); - _set_var($var[$k], $v, $type, $multibyte); - } - } - } else { - _set_var($var, $var, $type, $multibyte); - } - - return $var; -} - -/** - * Escaping SQL - */ -function attach_mod_sql_escape($text) -{ - if (function_exists('mysqli_real_escape_string')) { - return DB()->escape_string($text); - } - - return str_replace(['\\', "'"], ['\\\\', "''"], $text); -} - -/** - * Build sql statement from array for insert/update/select statements - * - * Idea for this from Ikonboard - * Possible query values: INSERT, INSERT_SELECT, MULTI_INSERT, UPDATE, SELECT - */ -function attach_mod_sql_build_array($query, $assoc_ary = false) -{ - if (!is_array($assoc_ary)) { - return false; - } - - $fields = []; - $values = []; - if ($query == 'INSERT' || $query == 'INSERT_SELECT') { - foreach ($assoc_ary as $key => $var) { - $fields[] = $key; - - if (null === $var) { - $values[] = 'NULL'; - } elseif (is_string($var)) { - $values[] = "'" . attach_mod_sql_escape($var) . "'"; - } elseif (is_array($var) && is_string($var[0])) { - $values[] = $var[0]; - } else { - $values[] = (is_bool($var)) ? (int)$var : $var; - } - } - - $query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' '; - } elseif ($query == 'MULTI_INSERT') { - $ary = []; - foreach ($assoc_ary as $id => $sql_ary) { - $values = []; - foreach ($sql_ary as $key => $var) { - if (null === $var) { - $values[] = 'NULL'; - } elseif (is_string($var)) { - $values[] = "'" . attach_mod_sql_escape($var) . "'"; - } else { - $values[] = (is_bool($var)) ? (int)$var : $var; - } - } - $ary[] = '(' . implode(', ', $values) . ')'; - } - - $query = ' (' . implode(', ', array_keys($assoc_ary[0])) . ') VALUES ' . implode(', ', $ary); - } elseif ($query == 'UPDATE' || $query == 'SELECT') { - $values = []; - foreach ($assoc_ary as $key => $var) { - if (null === $var) { - $values[] = "$key = NULL"; - } elseif (is_string($var)) { - $values[] = "$key = '" . attach_mod_sql_escape($var) . "'"; - } else { - $values[] = (is_bool($var)) ? "$key = " . (int)$var : "$key = $var"; - } - } - $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); - } - - return $query; -} diff --git a/library/attach_mod/includes/functions_delete.php b/library/attach_mod/includes/functions_delete.php deleted file mode 100644 index 93fa89a05..000000000 --- a/library/attach_mod/includes/functions_delete.php +++ /dev/null @@ -1,239 +0,0 @@ -sql_query($sql))) { - bb_die('Could not select ids'); - } - - $num_post_list = DB()->num_rows($result); - - if ($num_post_list == 0) { - DB()->sql_freeresult($result); - return; - } - - while ($row = DB()->sql_fetchrow($result)) { - $post_id_array[] = (int)$row[$p_id]; - } - DB()->sql_freeresult($result); - } - - if (!is_array($post_id_array)) { - if (trim($post_id_array) == '') { - return; - } - - if (false !== strpos($post_id_array, ', ')) { - $post_id_array = explode(', ', $post_id_array); - } elseif (false !== strpos($post_id_array, ',')) { - $post_id_array = explode(',', $post_id_array); - } else { - $post_id = (int)$post_id_array; - - $post_id_array = array(); - $post_id_array[] = $post_id; - } - } - - if (!count($post_id_array)) { - return; - } - - // First of all, determine the post id and attach_id - if ($attach_id_array === 0) { - $attach_id_array = array(); - - // Get the attach_ids to fill the array - $whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')'; - - $sql = 'SELECT attach_id - FROM ' . BB_ATTACHMENTS . " $whereclause - GROUP BY attach_id"; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not select attachment id #1'); - } - - $num_attach_list = DB()->num_rows($result); - - if ($num_attach_list == 0) { - DB()->sql_freeresult($result); - return; - } - - while ($row = DB()->sql_fetchrow($result)) { - $attach_id_array[] = (int)$row['attach_id']; - } - DB()->sql_freeresult($result); - } - - if (!is_array($attach_id_array)) { - if (false !== strpos($attach_id_array, ', ')) { - $attach_id_array = explode(', ', $attach_id_array); - } elseif (false !== strpos($attach_id_array, ',')) { - $attach_id_array = explode(',', $attach_id_array); - } else { - $attach_id = (int)$attach_id_array; - - $attach_id_array = array(); - $attach_id_array[] = $attach_id; - } - } - - if (!count($attach_id_array)) { - return; - } - - $sql_id = 'post_id'; - - if (count($post_id_array) && count($attach_id_array)) { - $sql = 'DELETE FROM ' . BB_ATTACHMENTS . ' - WHERE attach_id IN (' . implode(', ', $attach_id_array) . ") - AND $sql_id IN (" . implode(', ', $post_id_array) . ')'; - - if (!(DB()->sql_query($sql))) { - bb_die($lang['ERROR_DELETED_ATTACHMENTS']); - } - - //bt - if ($sql_id == 'post_id') { - $sql = "SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE attach_id IN(" . implode(',', $attach_id_array) . ")"; - - if (!$result = DB()->sql_query($sql)) { - bb_die($lang['ERROR_DELETED_ATTACHMENTS']); - } - - $torrents_sql = array(); - - while ($row = DB()->sql_fetchrow($result)) { - $torrents_sql[] = $row['topic_id']; - } - - if ($torrents_sql = implode(',', $torrents_sql)) { - // Remove peers from tracker - $sql = "DELETE FROM " . BB_BT_TRACKER . " - WHERE topic_id IN($torrents_sql)"; - - if (!DB()->sql_query($sql)) { - bb_die('Could not delete peers'); - } - } - // Delete torrents - $sql = "DELETE FROM " . BB_BT_TORRENTS . " - WHERE attach_id IN(" . implode(',', $attach_id_array) . ")"; - - if (!DB()->sql_query($sql)) { - bb_die($lang['ERROR_DELETED_ATTACHMENTS']); - } - } - //bt end - - foreach ($attach_id_array as $i => $iValue) { - $sql = 'SELECT attach_id - FROM ' . BB_ATTACHMENTS . ' - WHERE attach_id = ' . (int)$attach_id_array[$i]; - - 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) { - $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))) { - bb_die('Could not query attach description table'); - } - $num_rows = DB()->num_rows($result); - - if ($num_rows != 0) { - $num_attach = $num_rows; - $attachments = DB()->sql_fetchrowset($result); - DB()->sql_freeresult($result); - - // delete attachments - for ($j = 0; $j < $num_attach; $j++) { - unlink_attach($attachments[$j]['physical_filename']); - - if ((int)$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))) { - bb_die($lang['ERROR_DELETED_ATTACHMENTS']); - } - } - } else { - DB()->sql_freeresult($result); - } - } - } - } - - // Now Sync the Topic/PM - if (count($post_id_array)) { - $sql = 'SELECT topic_id - FROM ' . BB_POSTS . ' - WHERE post_id IN (' . implode(', ', $post_id_array) . ') - GROUP BY topic_id'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not select topic id'); - } - - while ($row = DB()->sql_fetchrow($result)) { - attachment_sync_topic($row['topic_id']); - } - DB()->sql_freeresult($result); - } -} diff --git a/library/attach_mod/includes/functions_filetypes.php b/library/attach_mod/includes/functions_filetypes.php deleted file mode 100644 index ed1f0e12b..000000000 --- a/library/attach_mod/includes/functions_filetypes.php +++ /dev/null @@ -1,258 +0,0 @@ -= 4294967294) { - $value -= 4294967296; - } - - return $value; -} - -/** - * Read Word (2 Bytes) from File - Note: It's an Intel Word - */ -function read_word($fp) -{ - $data = fread($fp, 2); - - return ord($data[1]) * 256 + ord($data[0]); -} - -/** - * Read Byte - */ -function read_byte($fp) -{ - $data = fread($fp, 1); - - return ord($data); -} - -/** - * Get Image Dimensions - */ -function image_getdimension($file) -{ - $xmax = null; - $xmin = null; - $ymax = null; - $ymin = null; - $size = @getimagesize($file); - - if ($size[0] != 0 || $size[1] != 0) { - return $size; - } - - // Try to get the Dimension manually, depending on the mimetype - $fp = @fopen($file, 'rb'); - if (!$fp) { - return $size; - } - - $error = false; - - // BMP - IMAGE - - $tmp_str = fread($fp, 2); - if ($tmp_str == 'BM') { - $length = read_longint($fp); - - if ($length <= 6) { - $error = true; - } - - if (!$error) { - $i = read_longint($fp); - if ($i != 0) { - $error = true; - } - } - - if (!$error) { - $i = read_longint($fp); - - if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36) { - $error = true; - } - } - - if (!$error) { - $tmp_str = fread($fp, 4); - $width = read_longint($fp); - $height = read_longint($fp); - - if ($width > 3000 || $height > 3000) { - $error = true; - } - } - } else { - $error = true; - } - - if (!$error) { - fclose($fp); - return array( - $width, - $height, - 6 - ); - } - - $error = false; - fclose($fp); - - // GIF - IMAGE - - $fp = @fopen($file, 'rb'); - - $tmp_str = fread($fp, 3); - - if ($tmp_str == 'GIF') { - $tmp_str = fread($fp, 3); - $width = read_word($fp); - $height = read_word($fp); - - $info_byte = fread($fp, 1); - $info_byte = ord($info_byte); - if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0) { - $error = true; - } - - if (!$error) { - if (($info_byte & 8) != 0) { - $error = true; - } - } - } else { - $error = true; - } - - if (!$error) { - fclose($fp); - return array( - $width, - $height, - 1 - ); - } - - $error = false; - fclose($fp); - - // JPG - IMAGE - $fp = @fopen($file, 'rb'); - - $tmp_str = fread($fp, 4); - $w1 = read_word($fp); - - if ((int)$w1 < 16) { - $error = true; - } - - if (!$error) { - $tmp_str = fread($fp, 4); - if ($tmp_str == 'JFIF') { - $o_byte = fread($fp, 1); - if ((int)$o_byte != 0) { - $error = true; - } - - if (!$error) { - $str = fread($fp, 2); - $b = read_byte($fp); - - if ($b != 0 && $b != 1 && $b != 2) { - $error = true; - } - } - - if (!$error) { - $width = read_word($fp); - $height = read_word($fp); - - if ($width <= 0 || $height <= 0) { - $error = true; - } - } - } - } else { - $error = true; - } - - if (!$error) { - fclose($fp); - return array( - $width, - $height, - 2 - ); - } - - $error = false; - fclose($fp); - - // PCX - IMAGE - - $fp = @fopen($file, 'rb'); - - $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)) { - $b = fread($fp, 1); - - if (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24) { - $error = true; - } - - if (!$error) { - $xmin = read_word($fp); - $ymin = read_word($fp); - $xmax = read_word($fp); - $ymax = read_word($fp); - $tmp_str = fread($fp, 52); - - $b = fread($fp, 1); - if ($b != 0) { - $error = true; - } - } - - if (!$error) { - $width = $xmax - $xmin + 1; - $height = $ymax - $ymin + 1; - } - } else { - $error = true; - } - - if (!$error) { - fclose($fp); - return array( - $width, - $height, - 7 - ); - } - - fclose($fp); - - return $size; -} diff --git a/library/attach_mod/includes/functions_includes.php b/library/attach_mod/includes/functions_includes.php deleted file mode 100644 index 5814c518c..000000000 --- a/library/attach_mod/includes/functions_includes.php +++ /dev/null @@ -1,172 +0,0 @@ -'; - $s_auth_can .= (($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT']) . '
'; -} - -/** - * Called from admin_users.php and admin_groups.php in order to process Quota Settings (admin/admin_users.php:admin/admin_groups.php) - */ -function attachment_quota_settings($admin_mode, $submit = false, $mode) -{ - global $template, $lang, $attach_config; - $this_userdata = []; - - if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) { - $upload_dir = $attach_config['upload_dir']; - } else { - $upload_dir = BB_ROOT . $attach_config['upload_dir']; - } - - include ATTACH_DIR . '/includes/functions_selects.php'; - if (!function_exists("process_quota_settings")) { - include ATTACH_DIR . '/includes/functions_admin.php'; - } - - $user_id = 0; - - if ($admin_mode == 'user') { - // We overwrite submit here... to be sure - $submit = (isset($_POST['submit'])) ? true : false; - - if (!$submit && $mode != 'save') { - $user_id = get_var(POST_USERS_URL, 0); - $u_name = get_var('username', ''); - - if (!$user_id && !$u_name) { - bb_die($lang['NO_USER_ID_SPECIFIED']); - } - - if ($user_id) { - $this_userdata['user_id'] = $user_id; - } else { - // Get userdata is handling the sanitizing of username - $this_userdata = get_userdata($_POST['username'], true); - } - - $user_id = (int)$this_userdata['user_id']; - } else { - $user_id = get_var('id', 0); - - if (!$user_id) { - bb_die($lang['NO_USER_ID_SPECIFIED']); - } - } - } - - if ($admin_mode == 'user' && !$submit && $mode != 'save') { - // Show the contents - $sql = 'SELECT quota_limit_id, quota_type FROM ' . BB_QUOTA . ' WHERE user_id = ' . (int)$user_id; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Unable to get quota settings #1'); - } - - $pm_quota = $upload_quota = 0; - - if ($row = DB()->sql_fetchrow($result)) { - do { - if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT) { - $upload_quota = $row['quota_limit_id']; - } elseif ($row['quota_type'] == QUOTA_PM_LIMIT) { - $pm_quota = $row['quota_limit_id']; - } - } while ($row = DB()->sql_fetchrow($result)); - } else { - // Set Default Quota Limit - $upload_quota = $attach_config['default_upload_quota']; - $pm_quota = $attach_config['default_pm_quota']; - } - DB()->sql_freeresult($result); - - $template->assign_vars(array( - 'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota), - 'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota), - )); - } - - if ($admin_mode == 'user' && $submit && @$_POST['delete_user']) { - process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, 0); - process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, 0); - } elseif ($admin_mode == 'user' && $submit && $mode == 'save') { - // Get the contents - $upload_quota = get_var('user_upload_quota', 0); - $pm_quota = get_var('user_pm_quota', 0); - - process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota); - process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota); - } - - if ($admin_mode == 'group' && $mode == 'newgroup') { - return; - } - - if ($admin_mode == 'group' && !$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))) { - 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) { - $upload_quota = $row['quota_limit_id']; - } elseif ($row['quota_type'] == QUOTA_PM_LIMIT) { - $pm_quota = $row['quota_limit_id']; - } - } while ($row = DB()->sql_fetchrow($result)); - } else { - // Set Default Quota Limit - $upload_quota = $attach_config['default_upload_quota']; - $pm_quota = $attach_config['default_pm_quota']; - } - DB()->sql_freeresult($result); - - $template->assign_vars(array( - 'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota), - 'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota), - )); - } - - if ($admin_mode == 'group' && $submit && isset($_POST['group_delete'])) { - $group_id = get_var(POST_GROUPS_URL, 0); - - process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, 0); - process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, 0); - } elseif ($admin_mode == 'group' && $submit) { - $group_id = get_var(POST_GROUPS_URL, 0); - - // Get the contents - $upload_quota = get_var('group_upload_quota', 0); - $pm_quota = get_var('group_pm_quota', 0); - - process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota); - process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota); - } -} diff --git a/library/attach_mod/includes/functions_selects.php b/library/attach_mod/includes/functions_selects.php deleted file mode 100644 index 711b78d82..000000000 --- a/library/attach_mod/includes/functions_selects.php +++ /dev/null @@ -1,232 +0,0 @@ -sql_query($sql))) { - bb_die('Could not query extension groups table #1'); - } - - $group_select = ''; - - return $group_select; -} - -/** - * select download mode - */ -function download_select($select_name, $group_id = 0) -{ - global $types_download, $modes_download; - - if ($group_id) { - $sql = 'SELECT download_mode - FROM ' . BB_EXTENSION_GROUPS . ' - WHERE group_id = ' . (int)$group_id; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query extension groups table #2'); - } - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - - if (!isset($row['download_mode'])) { - return ''; - } - - $download_mode = $row['download_mode']; - } - - $group_select = ''; - - return $group_select; -} - -/** - * select category types - */ -function category_select($select_name, $group_id = 0) -{ - global $types_category, $modes_category; - $category_type = null; - - $sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not select category'); - } - - $rows = DB()->sql_fetchrowset($result); - $num_rows = DB()->num_rows($result); - DB()->sql_freeresult($result); - - $type_category = 0; - - if ($num_rows > 0) { - for ($i = 0; $i < $num_rows; $i++) { - if ($group_id == $rows[$i]['group_id']) { - $category_type = $rows[$i]['cat_id']; - } - } - } - - $types = array(NONE_CAT); - $modes = array('none'); - - for ($i = 0, $iMax = count($types_category); $i < $iMax; $i++) { - $types[] = $types_category[$i]; - $modes[] = $modes_category[$i]; - } - - $group_select = ''; - - return $group_select; -} - -/** - * Select size mode - */ -function size_select($select_name, $size_compare) -{ - global $lang; - - $size_types_text = array($lang['BYTES'], $lang['KB'], $lang['MB']); - $size_types = array('b', 'kb', 'mb'); - - $select_field = ''; - - return $select_field; -} - -/** - * select quota limit - */ -function quota_limit_select($select_name, $default_quota = 0) -{ - global $lang; - $quota_name = []; - - $sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query quota limits table #1'); - } - - $quota_select = ''; - - return $quota_select; -} - -/** - * select default quota limit - */ -function default_quota_limit_select($select_name, $default_quota = 0) -{ - global $lang; - $quota_name = []; - - $sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query quota limits table #2'); - } - - $quota_select = ''; - - return $quota_select; -} diff --git a/library/attach_mod/includes/functions_thumbs.php b/library/attach_mod/includes/functions_thumbs.php deleted file mode 100644 index def96b034..000000000 --- a/library/attach_mod/includes/functions_thumbs.php +++ /dev/null @@ -1,177 +0,0 @@ - $height) { - return array( - round($width * ($max_width / $width)), - round($height * ($max_width / $width)) - ); - } - - return array( - round($width * ($max_width / $height)), - round($height * ($max_width / $height)) - ); -} - -/** - * Check if imagick is present - */ -function is_imagick() -{ - global $imagick, $attach_config; - - if ($attach_config['img_imagick'] != '') { - $imagick = $attach_config['img_imagick']; - return true; - } - - return false; -} - -/** - * Get supported image types - */ -function get_supported_image_types($type) -{ - if (@extension_loaded('gd')) { - $format = imagetypes(); - $new_type = 0; - - switch ($type) { - case 1: - $new_type = ($format & IMG_GIF) ? IMG_GIF : 0; - break; - case 2: - case 9: - case 10: - case 11: - case 12: - $new_type = ($format & IMG_JPG) ? IMG_JPG : 0; - break; - case 3: - $new_type = ($format & IMG_PNG) ? IMG_PNG : 0; - break; - case 6: - case 15: - $new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0; - break; - } - - return array( - 'gd' => ($new_type) ? true : false, - 'format' => $new_type, - 'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1 - ); - } - - return array('gd' => false); -} - -/** - * Create thumbnail - */ -function create_thumbnail($source, $new_file, $mimetype) -{ - global $attach_config, $imagick; - $image = null; - - $source = amod_realpath($source); - $min_filesize = (int)$attach_config['img_min_thumb_filesize']; - $img_filesize = (@file_exists($source)) ? @filesize($source) : false; - - if (!$img_filesize || $img_filesize <= $min_filesize) { - return false; - } - - [$width, $height, $type,] = getimagesize($source); - - if (!$width || !$height) { - return false; - } - - [$new_width, $new_height] = get_img_size_format($width, $height); - - $used_imagick = false; - - if (is_imagick()) { - passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"'); - if (@file_exists($new_file)) { - $used_imagick = true; - } - } - - if (!$used_imagick) { - $type = get_supported_image_types($type); - - if ($type['gd']) { - switch ($type['format']) { - case IMG_GIF: - $image = imagecreatefromgif($source); - break; - case IMG_JPG: - $image = imagecreatefromjpeg($source); - break; - case IMG_PNG: - $image = imagecreatefrompng($source); - break; - case IMG_WBMP: - $image = imagecreatefromwbmp($source); - break; - } - - if ($type['version'] == 1 || !$attach_config['use_gd2']) { - $new_image = imagecreate($new_width, $new_height); - imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - } else { - $new_image = imagecreatetruecolor($new_width, $new_height); - imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - } - - switch ($type['format']) { - case IMG_GIF: - imagegif($new_image, $new_file); - break; - case IMG_JPG: - imagejpeg($new_image, $new_file, 90); - break; - case IMG_PNG: - imagepng($new_image, $new_file); - break; - case IMG_WBMP: - imagewbmp($new_image, $new_file); - break; - } - - imagedestroy($new_image); - } - } - - if (!@file_exists($new_file)) { - return false; - } - - @chmod($new_file, 0664); - - return true; -} diff --git a/library/attach_mod/posting_attachments.php b/library/attach_mod/posting_attachments.php deleted file mode 100644 index 8d870ba7a..000000000 --- a/library/attach_mod/posting_attachments.php +++ /dev/null @@ -1,29 +0,0 @@ -posting_attachment_mod(); -} diff --git a/library/config.php b/library/config.php index 52710aded..9864a3b39 100644 --- a/library/config.php +++ b/library/config.php @@ -391,7 +391,6 @@ $bb_cfg['board_email_form'] = false; // can users send email to each other via b $bb_cfg['board_email_sig'] = ''; // this text will be attached to all emails the board sends $bb_cfg['board_email_sitename'] = $domain_name; // sitename used in all emails header -$bb_cfg['topic_notify_enabled'] = true; $bb_cfg['pm_notify_enabled'] = true; $bb_cfg['group_send_email'] = true; $bb_cfg['email_change_disabled'] = false; // disable changing email by user @@ -627,7 +626,6 @@ $bb_cfg['tracker'] = [ 'limit_seed_ips' => 0, 'limit_leech_ips' => 0, 'tor_topic_up' => true, - 'gold_silver_enabled' => true, 'retracker' => true, 'retracker_host' => 'http://retracker.local/announce', 'freeleech' => false, diff --git a/library/includes/cron/jobs/attach_maintenance.php b/library/includes/cron/jobs/attach_maintenance.php deleted file mode 100644 index bbc7f07ed..000000000 --- a/library/includes/cron/jobs/attach_maintenance.php +++ /dev/null @@ -1,207 +0,0 @@ -expect_slow_query(600); - -$fix_errors = true; -$debug_mode = false; - -$tmp_attach_tbl = 'tmp_attachments'; -$db_max_packet = 800000; -$sql_limit = 3000; - -$check_attachments = false; -$orphan_files = $orphan_db_attach = $orphan_tor = array(); -$posts_without_attach = $topics_without_attach = array(); - -DB()->query(" - CREATE TEMPORARY TABLE $tmp_attach_tbl ( - physical_filename VARCHAR(255) NOT NULL default '', - KEY physical_filename (physical_filename(20)) - ) ENGINE = MyISAM DEFAULT CHARSET = utf8 -"); -DB()->add_shutdown_query("DROP TEMPORARY TABLE IF EXISTS $tmp_attach_tbl"); - -// Get attach_mod config -$attach_dir = get_attachments_dir(); - -// Get all names of existed attachments and insert them into $tmp_attach_tbl -if ($dir = @opendir($attach_dir)) { - $check_attachments = true; - $files = array(); - $f_len = 0; - - while (false !== ($f = readdir($dir))) { - if ($f == 'index.php' || $f == '.htaccess' || is_dir("$attach_dir/$f") || is_link("$attach_dir/$f")) { - continue; - } - $f = DB()->escape($f); - $files[] = "('$f')"; - $f_len += strlen($f) + 5; - - if ($f_len > $db_max_packet) { - $files = implode(',', $files); - DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files"); - $files = array(); - $f_len = 0; - } - } - if ($files = implode(',', $files)) { - DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files"); - } - closedir($dir); -} - -if ($check_attachments) { - // Delete bad records - DB()->query(" - DELETE a, d - FROM " . BB_ATTACHMENTS_DESC . " d - LEFT JOIN " . BB_ATTACHMENTS . " a USING(attach_id) - WHERE ( - d.physical_filename = '' - OR d.real_filename = '' - OR d.extension = '' - OR d.mimetype = '' - OR d.filesize = 0 - OR d.filetime = 0 - OR a.post_id = 0 - ) - "); - - // Delete attachments that exist in file system but not exist in DB - $sql = "SELECT f.physical_filename - FROM $tmp_attach_tbl f - LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(physical_filename) - WHERE d.physical_filename IS NULL - LIMIT $sql_limit"; - - foreach (DB()->fetch_rowset($sql) as $row) { - if ($filename = basename($row['physical_filename'])) { - if ($fix_errors) { - @unlink("$attach_dir/$filename"); - @unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename); - } - if ($debug_mode) { - $orphan_files[] = "$attach_dir/$filename"; - } - } - } - // Find DB records for attachments that exist in DB but not exist in file system - $sql = "SELECT d.attach_id - FROM " . BB_ATTACHMENTS_DESC . " d - LEFT JOIN $tmp_attach_tbl f USING(physical_filename) - WHERE f.physical_filename IS NULL - LIMIT $sql_limit"; - - foreach (DB()->fetch_rowset($sql) as $row) { - $orphan_db_attach[] = $row['attach_id']; - } - // Attachment exist in DESC_TABLE but not exist in ATTACH_TABLE - $sql = "SELECT d.attach_id - FROM " . BB_ATTACHMENTS_DESC . " d - LEFT JOIN " . BB_ATTACHMENTS . " a USING(attach_id) - WHERE a.attach_id IS NULL - LIMIT $sql_limit"; - - foreach (DB()->fetch_rowset($sql) as $row) { - $orphan_db_attach[] = $row['attach_id']; - } - // Attachment exist in ATTACH_TABLE but not exist in DESC_TABLE - $sql = "SELECT a.attach_id - FROM " . BB_ATTACHMENTS . " a - LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(attach_id) - WHERE d.attach_id IS NULL - LIMIT $sql_limit"; - - foreach (DB()->fetch_rowset($sql) as $row) { - $orphan_db_attach[] = $row['attach_id']; - } - // Attachments without post - $sql = "SELECT a.attach_id - FROM " . BB_ATTACHMENTS . " a - LEFT JOIN " . BB_POSTS . " p USING(post_id) - WHERE p.post_id IS NULL - LIMIT $sql_limit"; - - foreach (DB()->fetch_rowset($sql) as $row) { - $orphan_db_attach[] = $row['attach_id']; - } - // Delete all orphan attachments - if ($orphans_sql = implode(',', $orphan_db_attach)) { - if ($fix_errors) { - DB()->query("DELETE FROM " . BB_ATTACHMENTS_DESC . " WHERE attach_id IN($orphans_sql)"); - DB()->query("DELETE FROM " . BB_ATTACHMENTS . " WHERE attach_id IN($orphans_sql)"); - } - } - - // Torrents without attachments - $sql = "SELECT tor.topic_id - FROM " . BB_BT_TORRENTS . " tor - LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(attach_id) - WHERE d.attach_id IS NULL - LIMIT $sql_limit"; - - foreach (DB()->fetch_rowset($sql) as $row) { - $orphan_tor[] = $row['topic_id']; - } - // Delete all orphan torrents - if ($orphans_sql = implode(',', $orphan_tor)) { - if ($fix_errors) { - DB()->query("DELETE FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($orphans_sql)"); - } - } - - // Check post_attachment markers - $sql = "SELECT p.post_id - FROM " . BB_POSTS . " p - LEFT JOIN " . BB_ATTACHMENTS . " a USING(post_id) - WHERE p.post_attachment = 1 - AND a.post_id IS NULL"; - - foreach (DB()->fetch_rowset($sql) as $row) { - $posts_without_attach[] = $row['post_id']; - } - if ($posts_sql = implode(',', $posts_without_attach)) { - if ($fix_errors) { - DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)"); - } - } - // Check topic_attachment markers - $sql = "SELECT t.topic_id - FROM " . BB_POSTS . " p, " . BB_TOPICS . " t - WHERE t.topic_id = p.topic_id - AND t.topic_attachment = 1 - GROUP BY p.topic_id - HAVING SUM(p.post_attachment) = 0"; - - foreach (DB()->fetch_rowset($sql) as $row) { - $topics_without_attach[] = $row['topic_id']; - } - if ($topics_sql = implode(',', $topics_without_attach)) { - if ($fix_errors) { - DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)"); - } - } -} -if ($debug_mode) { - prn_r($orphan_files, '$orphan_files'); - prn_r($orphan_db_attach, '$orphan_db_attach'); - prn_r($orphan_tor, '$orphan_tor'); - prn_r($posts_without_attach, '$posts_without_attach'); - prn_r($topics_without_attach, '$topics_without_attach'); -} - -DB()->query("DROP TEMPORARY TABLE $tmp_attach_tbl"); - -unset($fix_errors, $debug_mode); diff --git a/library/includes/datastore/build_attach_extensions.php b/library/includes/datastore/build_attach_extensions.php deleted file mode 100644 index 0ae940a0f..000000000 --- a/library/includes/datastore/build_attach_extensions.php +++ /dev/null @@ -1,26 +0,0 @@ -fetch_rowset(" - SELECT - e.extension, g.cat_id, g.download_mode, g.upload_icon - FROM - " . BB_EXTENSIONS . " e, - " . BB_EXTENSION_GROUPS . " g - WHERE - e.group_id = g.group_id - AND g.allow_group = 1 -"); - -$this->store('attach_extensions', $extensions); diff --git a/library/includes/functions.php b/library/includes/functions.php index d6642ce7c..d2d6d246a 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -171,7 +171,7 @@ $bf['user_opt'] = array( 'dis_avatar' => 2, // Запрет на аватар 'dis_pm' => 3, // Запрет на отправку ЛС 'user_viewonline' => 4, // Скрывать пребывание пользователя - 'user_notify' => 5, // Сообщать об ответах в отслеживаемых темах + 'user_notify' => 5, // Сообщать об ответах в отслеживаемых темах (не используется) 'user_notify_pm' => 6, // Сообщать о новых ЛС 'dis_passkey' => 7, // Запрет на добавление passkey, он же запрет на скачивание торрентов 'user_porn_forums' => 8, // Скрывать контент 18+ @@ -239,7 +239,7 @@ function setbit(&$int, $bit_num, $on) All results are returned as associative arrays, even when a single auth type is specified. - If available you can send an array (either one or two dimensional) containing the + If available you can send an array (either one or two-dimensional) containing the forum auth levels, this will prevent the auth function having to do its own lookup */ @@ -2014,11 +2014,6 @@ function is_gold($type) { global $lang, $bb_cfg; - if (!$bb_cfg['tracker']['gold_silver_enabled']) { - $is_gold = ''; - return $is_gold; - } - switch ($type) { case TOR_TYPE_GOLD: $is_gold = ' '; diff --git a/library/includes/page_header.php b/library/includes/page_header.php index b3832f42d..c298eb448 100644 --- a/library/includes/page_header.php +++ b/library/includes/page_header.php @@ -208,7 +208,6 @@ $template->assign_vars(array( 'SELECTED' => HTML_SELECTED, 'U_SEARCH_SELF_BY_LAST' => "search.php?uid={$userdata['user_id']}&o=5", - 'U_WATCHED_TOPICS' => "profile.php?mode=watch", )); if (!empty($bb_cfg['page']['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp'])) { diff --git a/library/includes/ucp/register.php b/library/includes/ucp/register.php index f6732920f..326f47dcd 100644 --- a/library/includes/ucp/register.php +++ b/library/includes/ucp/register.php @@ -330,7 +330,6 @@ foreach ($profile_fields as $field => $can_edit) { # 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change 'user_viewemail' => $reg_mode ? false : true, 'user_viewonline' => $reg_mode ? false : true, - 'user_notify' => $reg_mode ? true : true, 'user_notify_pm' => $reg_mode ? true : true, 'user_porn_forums' => $reg_mode ? false : true, 'user_dls' => $reg_mode ? false : true, diff --git a/library/includes/ucp/topic_watch.php b/library/includes/ucp/topic_watch.php deleted file mode 100644 index e68697a31..000000000 --- a/library/includes/ucp/topic_watch.php +++ /dev/null @@ -1,97 +0,0 @@ -sql_query($sql))) { - bb_die('Could not delete topic watch information #1'); - } -} - -$template->assign_vars(array( - 'PAGE_TITLE' => $lang['WATCHED_TOPICS'], - 'S_FORM_ACTION' => BB_ROOT . 'profile.php?mode=watch', -)); - -$sql = "SELECT COUNT(topic_id) as watch_count FROM " . BB_TOPICS_WATCH . " WHERE user_id = $user_id"; -if (!($result = DB()->sql_query($sql))) { - bb_die('Could not obtain watch topic information #2'); -} -$row = DB()->sql_fetchrow($result); -$watch_count = ($row['watch_count']) ?: 0; -DB()->sql_freeresult($result); - -if ($watch_count > 0) { - $sql = "SELECT w.*, t.*, f.*, u.*, u2.username as last_username, u2.user_id as last_user_id, - u2.user_level as last_user_level, u2.user_rank as last_user_rank - FROM " . BB_TOPICS_WATCH . " w, " . BB_TOPICS . " t, " . BB_USERS . " u, " . BB_FORUMS . " f, " . BB_POSTS . " p, " . BB_USERS . " u2 - WHERE w.topic_id = t.topic_id - AND t.forum_id = f.forum_id - AND p.post_id = t.topic_last_post_id - AND p.poster_id = u2.user_id - AND t.topic_poster = u.user_id - AND w.user_id = $user_id - GROUP BY t.topic_last_post_time DESC - LIMIT $start, $per_page"; - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not obtain watch topic information #3'); - } - $watch = DB()->sql_fetchrowset($result); - - if ($watch) { - for ($i = 0, $iMax = count($watch); $i < $iMax; $i++) { - $is_unread = is_unread($watch[$i]['topic_last_post_time'], $watch[$i]['topic_id'], $watch[$i]['forum_id']); - - $template->assign_block_vars('watch', array( - 'ROW_CLASS' => (!($i % 2)) ? 'row1' : 'row2', - 'POST_ID' => $watch[$i]['topic_first_post_id'], - 'TOPIC_ID' => $watch[$i]['topic_id'], - 'TOPIC_TITLE' => wbr(str_short($watch[$i]['topic_title'], 70)), - 'FULL_TOPIC_TITLE' => wbr($watch[$i]['topic_title']), - 'U_TOPIC' => TOPIC_URL . $watch[$i]['topic_id'], - 'FORUM_TITLE' => wbr($watch[$i]['forum_name']), - 'U_FORUM' => FORUM_URL . $watch[$i]['forum_id'], - 'REPLIES' => $watch[$i]['topic_replies'], - 'AUTHOR' => profile_url($watch[$i]), - 'LAST_POST' => bb_date($watch[$i]['topic_last_post_time']) . '
' . profile_url(array('user_id' => $watch[$i]['last_user_id'], 'username' => $watch[$i]['last_username'], 'user_rank' => $watch[$i]['last_user_rank'])), - 'LAST_POST_ID' => $watch[$i]['topic_last_post_id'], - 'IS_UNREAD' => $is_unread, - 'TOPIC_ICON' => get_topic_icon($watch[$i], $is_unread), - 'PAGINATION' => ($watch[$i]['topic_status'] == TOPIC_MOVED) ? '' : build_topic_pagination(TOPIC_URL . $watch[$i]['topic_id'], $watch[$i]['topic_replies'], $bb_cfg['posts_per_page']), - )); - } - - $template->assign_vars(array( - 'MATCHES' => (count($watch) == 1) ? sprintf($lang['FOUND_SEARCH_MATCH'], count($watch)) : sprintf($lang['FOUND_SEARCH_MATCHES'], count($watch)), - 'PAGINATION' => generate_pagination(BB_ROOT . 'profile.php?mode=watch', $watch_count, $per_page, $start), - 'PAGE_NUMBER' => sprintf($lang['PAGE_OF'], (floor($start / $per_page) + 1), ceil($watch_count / $per_page)), - 'U_PER_PAGE' => BB_ROOT . 'profile.php?mode=watch', - 'PER_PAGE' => $per_page, - )); - } - DB()->sql_freeresult($result); -} else { - meta_refresh('index.php', 3); - bb_die($lang['NO_WATCHED_TOPICS']); -} - -print_page('usercp_topic_watch.tpl'); diff --git a/library/language/source/email/topic_notify.html b/library/language/source/email/topic_notify.html deleted file mode 100644 index 79a41dbd6..000000000 --- a/library/language/source/email/topic_notify.html +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Topic Reply Notification - {TOPIC_TITLE} - -Hello, - -You are receiving this email because you are watching the topic, "{TOPIC_TITLE}" at {SITENAME}. This topic has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. - -{U_TOPIC} - -If you no longer wish to watch this topic you can either click the "Stop watching this topic link" found at the bottom of the topic above, or by clicking the following link: - -{U_STOP_WATCHING_TOPIC} - -{EMAIL_SIG} diff --git a/login.php b/login.php index 9faf97494..9ca9255db 100644 --- a/login.php +++ b/login.php @@ -9,7 +9,6 @@ define('BB_SCRIPT', 'login'); define('IN_LOGIN', true); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; array_deep($_POST, 'trim'); diff --git a/memberlist.php b/memberlist.php index 9c7967013..197265bb5 100644 --- a/memberlist.php +++ b/memberlist.php @@ -8,7 +8,6 @@ */ define('BB_SCRIPT', 'memberlist'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; $page_cfg['use_tablesorter'] = true; diff --git a/privmsg.php b/privmsg.php index 2c9889011..03dba6245 100644 --- a/privmsg.php +++ b/privmsg.php @@ -9,7 +9,6 @@ define('BB_SCRIPT', 'pm'); define('IN_PM', true); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; require INC_DIR . '/bbcode.php'; diff --git a/profile.php b/profile.php index 7031a5a3d..ab3b42675 100644 --- a/profile.php +++ b/profile.php @@ -9,7 +9,6 @@ define('IN_PROFILE', true); define('BB_SCRIPT', 'profile'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; // Start session management @@ -50,13 +49,6 @@ switch ($mode) { require UCP_DIR . '/bonus.php'; break; - case 'watch': - if (IS_GUEST) { - login_redirect(); - } - require UCP_DIR . '/topic_watch.php'; - break; - default: bb_die('Invalid mode'); } diff --git a/src/Legacy/Attach.php b/src/Legacy/Attach.php deleted file mode 100644 index b165a3173..000000000 --- a/src/Legacy/Attach.php +++ /dev/null @@ -1,1077 +0,0 @@ -add_attachment_body = get_var('add_attachment_body', 0); - $this->posted_attachments_body = get_var('posted_attachments_body', 0); - - $this->file_comment = get_var('filecomment', ''); - $this->attachment_id_list = get_var('attach_id_list', [0]); - $this->attachment_comment_list = get_var('comment_list', ['']); - $this->attachment_filesize_list = get_var('filesize_list', [0]); - $this->attachment_filetime_list = get_var('filetime_list', [0]); - $this->attachment_filename_list = get_var('filename_list', ['']); - $this->attachment_extension_list = get_var('extension_list', ['']); - $this->attachment_mimetype_list = get_var('mimetype_list', ['']); - - $this->filename = (isset($_FILES['fileupload'], $_FILES['fileupload']['name']) && $_FILES['fileupload']['name'] !== 'none') ? trim(stripslashes($_FILES['fileupload']['name'])) : ''; - - $this->attachment_list = get_var('attachment_list', ['']); - $this->attachment_thumbnail_list = get_var('attach_thumbnail_list', [0]); - } - - /** - * Get Quota Limits - * @param array $userdata_quota - * @param int $user_id - */ - public function get_quota_limits(array $userdata_quota, $user_id = 0) - { - global $attach_config; - - $priority = 'user;group'; - - if (IS_ADMIN) { - $attach_config['pm_filesize_limit'] = 0; // Unlimited - $attach_config['upload_filesize_limit'] = 0; // Unlimited - return; - } - - $quota_type = QUOTA_UPLOAD_LIMIT; - $limit_type = 'upload_filesize_limit'; - $default = 'attachment_quota'; - - if (!$user_id) { - $user_id = (int)$userdata_quota['user_id']; - } - - $priority = explode(';', $priority); - $found = false; - - foreach ($priority as $item) { - if ($item === 'group' && !$found) { - // Get Group Quota, if we find one, we have our quota - $sql = 'SELECT u.group_id - FROM ' . BB_USER_GROUP . ' u, ' . BB_GROUPS . ' g - WHERE g.group_single_user = 0 - AND u.user_pending = 0 - AND u.group_id = g.group_id - AND u.user_id = ' . (int)$user_id; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get user group'); - } - - $rows = DB()->sql_fetchrowset($result); - DB()->sql_freeresult($result); - - if ($rows) { - $group_id = []; - - foreach ($rows as $row) { - $group_id[] = (int)$row['group_id']; - } - - $sql = 'SELECT l.quota_limit - FROM ' . BB_QUOTA . ' q, ' . BB_QUOTA_LIMITS . ' l - WHERE q.group_id IN (' . implode(', ', $group_id) . ') - AND q.group_id <> 0 - AND q.quota_type = ' . (int)$quota_type . ' - AND q.quota_limit_id = l.quota_limit_id - ORDER BY l.quota_limit DESC - LIMIT 1'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get group quota'); - } - - if (DB()->num_rows($result)) { - $row = DB()->sql_fetchrow($result); - $attach_config[$limit_type] = $row['quota_limit']; - $found = true; - } - DB()->sql_freeresult($result); - } - } - - if ($item === 'user' && !$found) { - // Get User Quota, if the user is not in a group or the group has no quotas - $sql = 'SELECT l.quota_limit - FROM ' . BB_QUOTA . ' q, ' . BB_QUOTA_LIMITS . ' l - WHERE q.user_id = ' . $user_id . ' - AND q.user_id <> 0 - AND q.quota_type = ' . $quota_type . ' - AND q.quota_limit_id = l.quota_limit_id - LIMIT 1'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get user quota'); - } - - if (DB()->num_rows($result)) { - $row = DB()->sql_fetchrow($result); - $attach_config[$limit_type] = $row['quota_limit']; - $found = true; - } - DB()->sql_freeresult($result); - } - } - - if (!$found) { - // Set Default Quota Limit - $quota_id = (int)((int)$quota_type === QUOTA_UPLOAD_LIMIT) ? $attach_config['default_upload_quota'] : $attach_config['default_pm_quota']; - - if (!$quota_id) { - $attach_config[$limit_type] = $attach_config[$default]; - } else { - $sql = 'SELECT quota_limit - FROM ' . BB_QUOTA_LIMITS . ' - WHERE quota_limit_id = ' . (int)$quota_id . ' - LIMIT 1'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not get default quota limit'); - } - - if (DB()->num_rows($result) > 0) { - $row = DB()->sql_fetchrow($result); - $attach_config[$limit_type] = $row['quota_limit']; - } else { - $attach_config[$limit_type] = $attach_config[$default]; - } - DB()->sql_freeresult($result); - } - } - - // Never exceed the complete Attachment Upload Quota - if ($quota_type === QUOTA_UPLOAD_LIMIT) { - if ($attach_config[$limit_type] > $attach_config[$default]) { - $attach_config[$limit_type] = $attach_config[$default]; - } - } - } - - /** - * Handle all modes... (intern) - * @private - */ - public function handle_attachments($mode) - { - global $is_auth, $attach_config, $refresh, $post_id, $submit, $preview, $error, $error_msg, $lang; - - // - // ok, what shall we do ;) - // - - if (IS_ADMIN) { - $max_attachments = ADMIN_MAX_ATTACHMENTS; - } else { - $max_attachments = (int)$attach_config['max_attachments']; - } - - $sql_id = 'post_id'; - - // nothing, if the user is not authorized or attachment mod disabled - if ($attach_config['disable_mod'] || !$is_auth['auth_attachments']) { - return false; - } - - // Init Vars - $attachments = []; - - if (!$refresh) { - $add = isset($_POST['add_attachment']); - $delete = isset($_POST['del_attachment']); - $edit = isset($_POST['edit_comment']); - $update_attachment = isset($_POST['update_attachment']); - $del_thumbnail = isset($_POST['del_thumbnail']); - - $add_attachment_box = !empty($_POST['add_attachment_box']); - $posted_attachments_box = !empty($_POST['posted_attachments_box']); - - $refresh = $add || $delete || $edit || $del_thumbnail || $update_attachment || $add_attachment_box || $posted_attachments_box; - } - - // Get Attachments - $attachments = get_attachments_from_post($post_id); - - $auth = $is_auth['auth_edit'] || $is_auth['auth_mod']; - - if (!$submit && $mode === 'editpost' && $auth) { - if (!$refresh && !$preview && !$error) { - foreach ($attachments as $attachment) { - $this->attachment_list[] = $attachment['physical_filename']; - $this->attachment_comment_list[] = $attachment['comment']; - $this->attachment_filename_list[] = $attachment['real_filename']; - $this->attachment_extension_list[] = $attachment['extension']; - $this->attachment_mimetype_list[] = $attachment['mimetype']; - $this->attachment_filesize_list[] = $attachment['filesize']; - $this->attachment_filetime_list[] = $attachment['filetime']; - $this->attachment_id_list[] = $attachment['attach_id']; - $this->attachment_thumbnail_list[] = $attachment['thumbnail']; - } - } - } - - $this->num_attachments = is_countable($this->attachment_list) ? \count($this->attachment_list) : 0; - - if ($submit) { - if ($mode === 'newtopic' || $mode === 'reply' || $mode === 'editpost') { - if ($this->filename) { - if ($this->num_attachments < (int)$max_attachments) { - $this->upload_attachment(); - - if (!$error && $this->post_attach) { - array_unshift($this->attachment_list, $this->attach_filename); - array_unshift($this->attachment_comment_list, $this->file_comment); - array_unshift($this->attachment_filename_list, $this->filename); - array_unshift($this->attachment_extension_list, $this->extension); - array_unshift($this->attachment_mimetype_list, $this->type); - array_unshift($this->attachment_filesize_list, $this->filesize); - array_unshift($this->attachment_filetime_list, $this->filetime); - array_unshift($this->attachment_id_list, '0'); - array_unshift($this->attachment_thumbnail_list, $this->thumbnail); - - $this->file_comment = ''; - $this->post_attach = false; - } - } else { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['TOO_MANY_ATTACHMENTS'], (int)$max_attachments); - } - } - } - } - - if ($preview || $refresh || $error) { - $delete_attachment = isset($_POST['del_attachment']); - $delete_thumbnail = isset($_POST['del_thumbnail']); - - $add_attachment = isset($_POST['add_attachment']); - $edit_attachment = isset($_POST['edit_comment']); - $update_attachment = isset($_POST['update_attachment']); - - // Perform actions on temporary attachments - if ($delete_attachment || $delete_thumbnail) { - // store old values - $actual_id_list = get_var('attach_id_list', [0]); - $actual_comment_list = get_var('comment_list', ['']); - $actual_filename_list = get_var('filename_list', ['']); - $actual_extension_list = get_var('extension_list', ['']); - $actual_mimetype_list = get_var('mimetype_list', ['']); - $actual_filesize_list = get_var('filesize_list', [0]); - $actual_filetime_list = get_var('filetime_list', [0]); - - $actual_list = get_var('attachment_list', ['']); - $actual_thumbnail_list = get_var('attach_thumbnail_list', [0]); - - // clean values - $this->attachment_list = []; - $this->attachment_comment_list = []; - $this->attachment_filename_list = []; - $this->attachment_extension_list = []; - $this->attachment_mimetype_list = []; - $this->attachment_filesize_list = []; - $this->attachment_filetime_list = []; - $this->attachment_id_list = []; - $this->attachment_thumbnail_list = []; - - // restore values :) - if (isset($_POST['attachment_list'])) { - for ($i = 0, $iMax = is_countable($actual_list) ? \count($actual_list) : 0; $i < $iMax; $i++) { - $restore = false; - $del_thumb = false; - - if ($delete_thumbnail) { - if (!isset($_POST['del_thumbnail'][$actual_list[$i]])) { - $restore = true; - } else { - $del_thumb = true; - } - } - if ($delete_attachment) { - if (!isset($_POST['del_attachment'][$actual_list[$i]])) { - $restore = true; - } - } - - if ($restore) { - $this->attachment_list[] = $actual_list[$i]; - $this->attachment_comment_list[] = $actual_comment_list[$i]; - $this->attachment_filename_list[] = $actual_filename_list[$i]; - $this->attachment_extension_list[] = $actual_extension_list[$i]; - $this->attachment_mimetype_list[] = $actual_mimetype_list[$i]; - $this->attachment_filesize_list[] = $actual_filesize_list[$i]; - $this->attachment_filetime_list[] = $actual_filetime_list[$i]; - $this->attachment_id_list[] = $actual_id_list[$i]; - $this->attachment_thumbnail_list[] = $actual_thumbnail_list[$i]; - } elseif (!$del_thumb) { - // delete selected attachment - if ($actual_id_list[$i] == '0') { - unlink_attach($actual_list[$i]); - - if ($actual_thumbnail_list[$i] == 1) { - unlink_attach($actual_list[$i], MODE_THUMBNAIL); - } - } else { - delete_attachment($post_id, $actual_id_list[$i], $this->page); - } - } elseif ($del_thumb) { - // delete selected thumbnail - $this->attachment_list[] = $actual_list[$i]; - $this->attachment_comment_list[] = $actual_comment_list[$i]; - $this->attachment_filename_list[] = $actual_filename_list[$i]; - $this->attachment_extension_list[] = $actual_extension_list[$i]; - $this->attachment_mimetype_list[] = $actual_mimetype_list[$i]; - $this->attachment_filesize_list[] = $actual_filesize_list[$i]; - $this->attachment_filetime_list[] = $actual_filetime_list[$i]; - $this->attachment_id_list[] = $actual_id_list[$i]; - $this->attachment_thumbnail_list[] = 0; - - if ($actual_id_list[$i] == 0) { - unlink_attach($actual_list[$i], MODE_THUMBNAIL); - } else { - $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET thumbnail = 0 WHERE attach_id = ' . (int)$actual_id_list[$i]; - - if (!(DB()->sql_query($sql))) { - bb_die('Unable to update ' . BB_ATTACHMENTS_DESC); - } - } - } - } - } - } elseif ($edit_attachment || $update_attachment || $add_attachment || $preview) { - if ($edit_attachment) { - $actual_comment_list = get_var('comment_list', ['']); - - $this->attachment_comment_list = []; - - for ($i = 0, $iMax = is_countable($this->attachment_list) ? \count($this->attachment_list) : 0; $i < $iMax; $i++) { - $this->attachment_comment_list[$i] = $actual_comment_list[$i]; - } - } - - if ($update_attachment) { - if (empty($this->filename)) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= $lang['ERROR_EMPTY_ADD_ATTACHBOX']; - } - - $this->upload_attachment(); - - if (!$error) { - $actual_id_list = get_var('attach_id_list', [0]); - - $attachment_id = 0; - $actual_element = 0; - - for ($i = 0, $iMax = is_countable($actual_id_list) ? \count($actual_id_list) : 0; $i < $iMax; $i++) { - if (isset($_POST['update_attachment'][$actual_id_list[$i]])) { - $attachment_id = (int)$actual_id_list[$i]; - $actual_element = $i; - } - } - - // Get current informations to delete the Old Attachment - $sql = 'SELECT physical_filename, comment, thumbnail - FROM ' . BB_ATTACHMENTS_DESC . ' - WHERE attach_id = ' . (int)$attachment_id; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Unable to select old attachment entry'); - } - - if (DB()->num_rows($result) != 1) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= $lang['ERROR_MISSING_OLD_ENTRY']; - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - - $comment = !trim($this->file_comment) ? trim($row['comment']) : trim($this->file_comment); - - // Update Entry - $sql_ary = [ - 'physical_filename' => (string)basename($this->attach_filename), - 'real_filename' => (string)basename($this->filename), - 'comment' => (string)$comment, - 'extension' => (string)strtolower($this->extension), - 'mimetype' => (string)strtolower($this->type), - 'filesize' => (int)$this->filesize, - 'filetime' => (int)$this->filetime, - 'thumbnail' => (int)$this->thumbnail - ]; - - $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . ' - WHERE attach_id = ' . (int)$attachment_id; - - if (!(DB()->sql_query($sql))) { - bb_die('Unable to update the attachment'); - } - - // Delete the Old Attachment - unlink_attach($row['physical_filename']); - - if ((int)$row['thumbnail'] === 1) { - unlink_attach($row['physical_filename'], MODE_THUMBNAIL); - } - - //bt - if ($this->attachment_extension_list[$actual_element] === TORRENT_EXT && $attachments[$actual_element]['tracker_status']) { - Torrent::tracker_unregister($attachment_id); - } - //bt end - - // Make sure it is displayed - $this->attachment_list[$actual_element] = $this->attach_filename; - $this->attachment_comment_list[$actual_element] = $comment; - $this->attachment_filename_list[$actual_element] = $this->filename; - $this->attachment_extension_list[$actual_element] = $this->extension; - $this->attachment_mimetype_list[$actual_element] = $this->type; - $this->attachment_filesize_list[$actual_element] = $this->filesize; - $this->attachment_filetime_list[$actual_element] = $this->filetime; - $this->attachment_id_list[$actual_element] = $actual_id_list[$actual_element]; - $this->attachment_thumbnail_list[$actual_element] = $this->thumbnail; - $this->file_comment = ''; - } - } - - if (($add_attachment || $preview) && !empty($this->filename)) { - if ($this->num_attachments < (int)$max_attachments) { - $this->upload_attachment(); - - if (!$error) { - array_unshift($this->attachment_list, $this->attach_filename); - array_unshift($this->attachment_comment_list, $this->file_comment); - array_unshift($this->attachment_filename_list, $this->filename); - array_unshift($this->attachment_extension_list, $this->extension); - array_unshift($this->attachment_mimetype_list, $this->type); - array_unshift($this->attachment_filesize_list, $this->filesize); - array_unshift($this->attachment_filetime_list, $this->filetime); - array_unshift($this->attachment_id_list, '0'); - array_unshift($this->attachment_thumbnail_list, $this->thumbnail); - - $this->file_comment = ''; - } - } else { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['TOO_MANY_ATTACHMENTS'], (int)$max_attachments); - } - } - } - } - - return true; - } - - /** - * Basic Insert Attachment Handling for all Message Types - */ - public function do_insert_attachment($mode, $message_type, $message_id) - { - global $upload_dir; - - if ((int)$message_id < 0) { - return false; - } - - global $post_info, $userdata; - - $post_id = (int)$message_id; - $user_id_1 = (isset($post_info['poster_id'])) ? (int)$post_info['poster_id'] : 0; - - if (!$user_id_1) { - $user_id_1 = (int)$userdata['user_id']; - } - - if ($mode === 'attach_list') { - for ($i = 0, $iMax = is_countable($this->attachment_list) ? \count($this->attachment_list) : 0; $i < $iMax; $i++) { - if ($this->attachment_id_list[$i]) { - //bt - if ($this->attachment_extension_list[$i] === TORRENT_EXT && !\defined('TORRENT_ATTACH_ID')) { - \define('TORRENT_ATTACH_ID', $this->attachment_id_list[$i]); - } - //bt end - - // update entry in db if attachment already stored in db and filespace - $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . " - SET comment = '" . @attach_mod_sql_escape($this->attachment_comment_list[$i]) . "' - WHERE attach_id = " . $this->attachment_id_list[$i]; - - if (!(DB()->sql_query($sql))) { - bb_die('Unable to update the file comment'); - } - } else { - if (empty($this->attachment_mimetype_list[$i]) && $this->attachment_extension_list[$i] === TORRENT_EXT) { - $this->attachment_mimetype_list[$i] = 'application/x-bittorrent'; - } - - // insert attachment into db - $sql_ary = [ - 'physical_filename' => (string)basename($this->attachment_list[$i]), - 'real_filename' => (string)basename($this->attachment_filename_list[$i]), - 'comment' => (string)@$this->attachment_comment_list[$i], - 'extension' => (string)strtolower($this->attachment_extension_list[$i]), - 'mimetype' => (string)strtolower($this->attachment_mimetype_list[$i]), - 'filesize' => (int)$this->attachment_filesize_list[$i], - 'filetime' => (int)$this->attachment_filetime_list[$i], - 'thumbnail' => (int)$this->attachment_thumbnail_list[$i] - ]; - - $sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary); - - if (!(DB()->sql_query($sql))) { - bb_die('Could not store Attachment.
Your ' . $message_type . ' has been stored'); - } - - $attach_id = DB()->sql_nextid(); - - //bt - if ($this->attachment_extension_list[$i] === TORRENT_EXT && !\defined('TORRENT_ATTACH_ID')) { - \define('TORRENT_ATTACH_ID', $attach_id); - } - //bt end - - $sql_ary = [ - 'attach_id' => (int)$attach_id, - 'post_id' => (int)$post_id, - 'user_id_1' => (int)$user_id_1, - ]; - - $sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary); - - if (!(DB()->sql_query($sql))) { - bb_die('Could not store Attachment.
Your ' . $message_type . ' has been stored'); - } - } - } - - return true; - } - - if ($mode === 'last_attachment') { - if ($this->post_attach && !isset($_POST['update_attachment'])) { - // insert attachment into db, here the user submited it directly - $sql_ary = [ - 'physical_filename' => (string)basename($this->attach_filename), - 'real_filename' => (string)basename($this->filename), - 'comment' => (string)$this->file_comment, - 'extension' => (string)strtolower($this->extension), - 'mimetype' => (string)strtolower($this->type), - 'filesize' => (int)$this->filesize, - 'filetime' => (int)$this->filetime, - 'thumbnail' => (int)$this->thumbnail - ]; - - $sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary); - - // Inform the user that his post has been created, but nothing is attached - if (!(DB()->sql_query($sql))) { - bb_die('Could not store Attachment.
Your ' . $message_type . ' has been stored'); - } - - $attach_id = DB()->sql_nextid(); - - $sql_ary = [ - 'attach_id' => (int)$attach_id, - 'post_id' => (int)$post_id, - 'user_id_1' => (int)$user_id_1, - ]; - - $sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary); - - if (!(DB()->sql_query($sql))) { - bb_die('Could not store Attachment.
Your ' . $message_type . ' has been stored'); - } - } - } - } - - /** - * Attachment Mod entry switch/output (intern) - * @private - */ - public function display_attachment_bodies() - { - global $attach_config, $is_auth, $lang, $template, $upload_dir, $forum_id; - - // Choose what to display - $value_add = $value_posted = 0; - - $this->add_attachment_body = 1; - $this->posted_attachments_body = 1; - - $s_hidden = ''; - $s_hidden .= ''; - - $template->assign_vars([ - 'ADD_ATTACH_HIDDEN_FIELDS' => $s_hidden, - ]); - - $attachments = []; - - if ($this->attachment_list) { - $hidden = ''; - for ($i = 0, $iMax = is_countable($this->attachment_list) ? \count($this->attachment_list) : 0; $i < $iMax; $i++) { - $hidden .= ''; - $hidden .= ''; - $hidden .= ''; - $hidden .= ''; - $hidden .= ''; - $hidden .= ''; - $hidden .= ''; - $hidden .= ''; - - if (!$this->posted_attachments_body || !$this->attachment_list) { - $hidden .= ''; - } - } - $template->assign_var('POSTED_ATTACHMENTS_HIDDEN_FIELDS', $hidden); - } - - if ($this->add_attachment_body) { - $template->assign_vars([ - 'TPL_ADD_ATTACHMENT' => true, - 'FILE_COMMENT' => htmlspecialchars($this->file_comment), - 'FILESIZE' => $attach_config['max_filesize'], - 'FILENAME' => htmlspecialchars($this->filename), - 'S_FORM_ENCTYPE' => 'enctype="multipart/form-data"', - ]); - } - - if ($this->posted_attachments_body && $this->attachment_list) { - $template->assign_vars([ - 'TPL_POSTED_ATTACHMENTS' => true, - ]); - - for ($i = 0, $iMax = is_countable($this->attachment_list) ? \count($this->attachment_list) : 0; $i < $iMax; $i++) { - if (@$this->attachment_id_list[$i] == 0) { - $download_link = $upload_dir . '/' . basename($this->attachment_list[$i]); - } else { - $download_link = BB_ROOT . DL_URL . $this->attachment_id_list[$i]; - } - - $template->assign_block_vars('attach_row', [ - 'FILE_NAME' => @htmlspecialchars($this->attachment_filename_list[$i]), - 'ATTACH_FILENAME' => @$this->attachment_list[$i], - 'FILE_COMMENT' => @htmlspecialchars($this->attachment_comment_list[$i]), - 'ATTACH_ID' => @$this->attachment_id_list[$i], - 'U_VIEW_ATTACHMENT' => $download_link, - ]); - - // Thumbnail there ? And is the User Admin or Mod ? Then present the 'Delete Thumbnail' Button - if ((int)$this->attachment_thumbnail_list[$i] === 1 && ((isset($is_auth['auth_mod']) && $is_auth['auth_mod']) || IS_ADMIN)) { - $template->assign_block_vars('attach_row.switch_thumbnail', []); - } - - if (@$this->attachment_id_list[$i]) { - $template->assign_block_vars('attach_row.switch_update_attachment', []); - } - } - } - - $template->assign_var('ATTACHBOX'); - } - - /** - * Upload an Attachment to Filespace (intern) - */ - public function upload_attachment() - { - global $error, $error_msg, $lang, $attach_config, $userdata, $upload_dir, $forum_id; - - $this->post_attach = (bool)$this->filename; - - if ($this->post_attach) { - $r_file = trim(basename($this->filename)); - $file = $_FILES['fileupload']['tmp_name']; - $this->type = $_FILES['fileupload']['type']; - - if (isset($_FILES['fileupload']['size']) && $_FILES['fileupload']['size'] == 0) { - bb_die('Tried to upload empty file'); - } - - $this->type = strtolower($this->type); - $this->extension = strtolower(get_extension($this->filename)); - - $this->filesize = @filesize($file); - $this->filesize = (int)$this->filesize; - - $sql = 'SELECT g.allow_group, g.max_filesize, g.cat_id, g.forum_permissions - FROM ' . BB_EXTENSION_GROUPS . ' g, ' . BB_EXTENSIONS . " e - WHERE g.group_id = e.group_id - AND e.extension = '" . attach_mod_sql_escape($this->extension) . "' - LIMIT 1"; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query extensions'); - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - - $allowed_filesize = $row['max_filesize'] ?: $attach_config['max_filesize']; - $cat_id = (int)$row['cat_id']; - $auth_cache = trim($row['forum_permissions']); - - // check Filename - if (preg_match("#[\\/:*?\"<>|]#i", $this->filename)) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['INVALID_FILENAME'], htmlspecialchars($this->filename)); - } - - // check php upload-size - if (!$error && $file === 'none') { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $ini_val = 'ini_get'; - - $max_size = @$ini_val('upload_max_filesize'); - - if (empty($max_size)) { - $error_msg .= $lang['ATTACHMENT_PHP_SIZE_NA']; - } else { - $error_msg .= sprintf($lang['ATTACHMENT_PHP_SIZE_OVERRUN'], $max_size); - } - } - - // Check Extension - if (!$error && (int)$row['allow_group'] == 0) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['DISALLOWED_EXTENSION'], htmlspecialchars($this->extension)); - } - - // Check Forum Permissions - if (!$error && !IS_ADMIN && !is_forum_authed($auth_cache, $forum_id) && trim($auth_cache)) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['DISALLOWED_EXTENSION_WITHIN_FORUM'], htmlspecialchars($this->extension)); - } - - //bt - // Check if user can post torrent - global $post_data; - - if (!$error && $this->extension === TORRENT_EXT && !$post_data['first_post']) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= $lang['ALLOWED_ONLY_1ST_POST_ATTACH']; - } - //bt end - - // Upload File - - $this->thumbnail = 0; - - if (!$error) { - // - // Prepare Values - $this->filetime = TIMENOW; - - $this->filename = $r_file; - - // physical filename - //$this->attach_filename = strtolower($this->filename); - $this->attach_filename = $this->filename; - - //bt - if (FILENAME_CRYPTIC) { - $this->attach_filename = make_rand_str(FILENAME_CRYPTIC_LENGTH); - } else { // original - $this->attach_filename = html_entity_decode(trim(stripslashes($this->attach_filename))); - $this->attach_filename = delete_extension($this->attach_filename); - $this->attach_filename = str_replace([' ', '-'], '_', $this->attach_filename); - $this->attach_filename = str_replace('__', '_', $this->attach_filename); - $this->attach_filename = str_replace([',', '.', '!', '?', 'ь', 'Ь', 'ц', 'Ц', 'д', 'Д', ';', ':', '@', "'", '"', '&'], ['', '', '', '', 'ue', 'ue', 'oe', 'oe', 'ae', 'ae', '', '', '', '', '', 'and'], $this->attach_filename); - $this->attach_filename = str_replace(['$', 'Я', '>', '<', '§', '%', '=', '/', '(', ')', '#', '*', '+', "\\", '{', '}', '[', ']'], ['dollar', 'ss', 'greater', 'lower', 'paragraph', 'percent', 'equal', '', '', '', '', '', '', '', '', '', '', ''], $this->attach_filename); - // Remove non-latin characters - $this->attach_filename = preg_replace('#([\xC2\xC3])([\x80-\xBF])#', 'chr(ord(\'$1\')<<6&0xC0|ord(\'$2\')&0x3F)', $this->attach_filename); - $this->attach_filename = rawurlencode($this->attach_filename); - $this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename); - $this->attach_filename = trim($this->attach_filename . time()); - } - $this->attach_filename = str_replace(['&', '&', ' '], '_', $this->attach_filename); - $this->attach_filename = str_replace('php', '_php_', $this->attach_filename); - $this->attach_filename = substr(trim($this->attach_filename), 0, FILENAME_MAX_LENGTH); - - for ($i = 0, $max_try = 5; $i <= $max_try; $i++) { - $fn_prefix = make_rand_str(FILENAME_PREFIX_LENGTH) . '_'; - $new_physical_filename = clean_filename($fn_prefix . $this->attach_filename); - - if (!physical_filename_already_stored($new_physical_filename)) { - break; - } - if ($i === $max_try) { - bb_die('Could not create filename for attachment'); - } - - $this->attach_filename = $new_physical_filename; - } - - - // Do we have to create a thumbnail ? - if ($cat_id == IMAGE_CAT && (int)$attach_config['img_create_thumbnail']) { - $this->thumbnail = 1; - } - } - - if ($error) { - $this->post_attach = false; - return; - } - - // Upload Attachment - if (!$error) { - // Descide the Upload method - $ini_val = 'ini_get'; - - if (@$ini_val('open_basedir')) { - $upload_mode = 'move'; - } elseif (@$ini_val('safe_mode')) { - $upload_mode = 'move'; - } else { - $upload_mode = 'copy'; - } - - // Ok, upload the Attachment - if (!$error) { - $this->move_uploaded_attachment($upload_mode, $file); - } - } - - // Now, check filesize parameters - if (!$error) { - if (!$this->filesize) { - $this->filesize = (int)@filesize($upload_dir . '/' . $this->attach_filename); - } - } - - // Check Image Size, if it's an image - if (!$error && !IS_ADMIN && $cat_id === IMAGE_CAT) { - [$width, $height] = image_getdimension($upload_dir . '/' . $this->attach_filename); - - if ($width && $height && (int)$attach_config['img_max_width'] && (int)$attach_config['img_max_height']) { - if ($width > (int)$attach_config['img_max_width'] || $height > (int)$attach_config['img_max_height']) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['ERROR_IMAGESIZE'], (int)$attach_config['img_max_width'], (int)$attach_config['img_max_height']); - } - } - } - - // check Filesize - if (!$error && $allowed_filesize && $this->filesize > $allowed_filesize && !(IS_ADMIN || IS_MOD || IS_GROUP_MEMBER)) { - $allowed_filesize = humn_size($allowed_filesize); - - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['ATTACHMENT_TOO_BIG'], $allowed_filesize); - } - - // Check our complete quota - if ($attach_config['attachment_quota']) { - $sql = 'SELECT sum(filesize) as total FROM ' . BB_ATTACHMENTS_DESC; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query total filesize #1'); - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - - $total_filesize = $row['total']; - - if (($total_filesize + $this->filesize) > $attach_config['attachment_quota']) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= $lang['ATTACH_QUOTA_REACHED']; - } - } - - $this->get_quota_limits($userdata); - - // Check our user quota - if ($attach_config['upload_filesize_limit']) { - $sql = 'SELECT attach_id - FROM ' . BB_ATTACHMENTS . ' - WHERE user_id_1 = ' . (int)$userdata['user_id'] . ' - GROUP BY attach_id'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query attachments'); - } - - $attach_ids = DB()->sql_fetchrowset($result); - $num_attach_ids = DB()->num_rows($result); - DB()->sql_freeresult($result); - - $attach_id = []; - - for ($i = 0; $i < $num_attach_ids; $i++) { - $attach_id[] = (int)$attach_ids[$i]['attach_id']; - } - - if ($num_attach_ids > 0) { - // Now get the total filesize - $sql = 'SELECT sum(filesize) as total - FROM ' . BB_ATTACHMENTS_DESC . ' - WHERE attach_id IN (' . implode(', ', $attach_id) . ')'; - - if (!($result = DB()->sql_query($sql))) { - bb_die('Could not query total filesize #2'); - } - - $row = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); - $total_filesize = $row['total']; - } else { - $total_filesize = 0; - } - - if (($total_filesize + $this->filesize) > $attach_config['upload_filesize_limit']) { - $upload_filesize_limit = $attach_config['upload_filesize_limit']; - $size_lang = ($upload_filesize_limit >= 1048576) ? $lang['MB'] : (($upload_filesize_limit >= 1024) ? $lang['KB'] : $lang['BYTES']); - - if ($upload_filesize_limit >= 1048576) { - $upload_filesize_limit = round($upload_filesize_limit / 1048576 * 100) / 100; - } elseif ($upload_filesize_limit >= 1024) { - $upload_filesize_limit = round($upload_filesize_limit / 1024 * 100) / 100; - } - - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['USER_UPLOAD_QUOTA_REACHED'], $upload_filesize_limit, $size_lang); - } - } - - if ($error) { - unlink_attach($this->attach_filename); - unlink_attach($this->attach_filename, MODE_THUMBNAIL); - $this->post_attach = false; - } - } - } - - // Copy the temporary attachment to the right location (copy, move_uploaded_file) - public function move_uploaded_attachment($upload_mode, $file) - { - global $error, $error_msg, $lang, $upload_dir; - - if (!is_uploaded_file($file)) { - bb_die('Unable to upload file. The given source has not been uploaded'); - } - - switch ($upload_mode) { - case 'copy': - - if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) { - if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['GENERAL_UPLOAD_ERROR'], './' . $upload_dir . '/' . $this->attach_filename); - return; - } - } - @chmod($upload_dir . '/' . basename($this->attach_filename), 0666); - - break; - - case 'move': - - if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) { - if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) { - $error = true; - if (!empty($error_msg)) { - $error_msg .= '
'; - } - $error_msg .= sprintf($lang['GENERAL_UPLOAD_ERROR'], './' . $upload_dir . '/' . $this->attach_filename); - return; - } - } - @chmod($upload_dir . '/' . $this->attach_filename, 0666); - - break; - } - - if (!$error && $this->thumbnail === 1) { - $source = $upload_dir . '/' . basename($this->attach_filename); - $dest_file = amod_realpath($upload_dir); - $dest_file .= '/' . THUMB_DIR . '/t_' . basename($this->attach_filename); - - if (!create_thumbnail($source, $dest_file, $this->type)) { - if (!$file || !create_thumbnail($file, $dest_file, $this->type)) { - $this->thumbnail = 0; - } - } - } - } -} diff --git a/styles/templates/admin/admin_attach_cp.tpl b/styles/templates/admin/admin_attach_cp.tpl deleted file mode 100644 index f86398e39..000000000 --- a/styles/templates/admin/admin_attach_cp.tpl +++ /dev/null @@ -1,256 +0,0 @@ -

{L_CONTROL_PANEL_TITLE}

- -

{L_CONTROL_PANEL_EXPLAIN}

-
- - - - -
- - - - -
{L_VIEW}: {S_VIEW_SELECT}   - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_STATISTIC}{L_VALUE}
{L_NUMBER_OF_ATTACHMENTS}:{NUMBER_OF_ATTACHMENTS}
{L_TOTAL_FILESIZE}:{TOTAL_FILESIZE}
{L_ATTACH_QUOTA}:{ATTACH_QUOTA}
{L_NUMBER_POSTS_ATTACH}:{NUMBER_OF_POSTS}
{L_NUMBER_PMS_ATTACH}:{NUMBER_OF_PMS}
{L_NUMBER_TOPICS_ATTACH}:{NUMBER_OF_TOPICS}
{L_NUMBER_USERS_ATTACH}:{NUMBER_OF_USERS}
-
- - - - - - - -
- - - - -
{L_VIEW}: {S_VIEW_SELECT}   - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_ATTACH_SEARCH_QUERY}
{L_FILENAME}:
{L_SEARCH_WILDCARD_EXPLAIN}
{L_FILE_COMMENT}:
{L_SEARCH_WILDCARD_EXPLAIN}
{L_SEARCH_AUTHOR}:
{L_SEARCH_WILDCARD_EXPLAIN}
{L_SIZE_SMALLER_THAN}:
{L_SIZE_GREATER_THAN}:
{L_COUNT_SMALLER_THAN}:
{L_COUNT_GREATER_THAN}:
{L_MORE_DAYS_OLD}:
{L_SEARCH_OPTIONS}
{L_FORUM}:
{L_SORT_BY}: {S_SORT_OPTIONS}
{L_SORT}: {S_SORT_ORDER}
{S_HIDDEN_FIELDS}
- -
- - - - - - - -
- - - - -
- {L_VIEW}: {S_VIEW_SELECT}  {L_SORT_BY}: {S_MODE_SELECT}  {L_ORDER} {S_ORDER_SELECT}   - - -
- - - - - - - - - - - - - - - -
#{L_USERNAME}{L_ATTACHMENTS}{L_SIZE_IN_KB}
 {memberrow.ROW_NUMBER} {memberrow.USERNAME} {memberrow.TOTAL_ATTACHMENTS}  {memberrow.TOTAL_SIZE} 
- - - - - - -
{PAGE_NUMBER}{PAGINATION} 
-
- - - - - - - - -{L_STATISTICS_FOR_USER} - - - - -
- - - - -
- {L_VIEW}: {S_VIEW_SELECT}  {L_SORT_BY}: {S_MODE_SELECT}  {L_ORDER} {S_ORDER_SELECT}   - - -
- - - - - - - - - - - - - - - - - - - - - - - - {attachrow.S_HIDDEN} - - - - - -
#{L_FILENAME}{L_FILE_COMMENT}{L_EXTENSION}{L_SIZE}{L_DOWNLOADS}{L_POST_TIME}{L_POSTED_IN_TOPIC}{L_DELETE}
 {attachrow.ROW_NUMBER} {attachrow.FILENAME}{attachrow.EXTENSION}{attachrow.SIZE}{attachrow.POST_TIME}{attachrow.POST_TITLE}{attachrow.S_DELETE_BOX}
- -   - -
- - - {S_USER_HIDDEN} - - - - - - -
{L_MARK_ALL} :: {L_UNMARK_ALL}
- - - - - - -
{PAGE_NUMBER}{PAGINATION} 
-
- - - - -
diff --git a/styles/templates/admin/admin_attachments.tpl b/styles/templates/admin/admin_attachments.tpl deleted file mode 100644 index 638029408..000000000 --- a/styles/templates/admin/admin_attachments.tpl +++ /dev/null @@ -1,302 +0,0 @@ - - - -

{L_MANAGE_CATEGORIES}

- -

{L_MANAGE_CATEGORIES_EXPLAIN}

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_SETTINGS_CAT_IMAGES}
{L_ASSIGNED_GROUP}: {S_ASSIGNED_GROUP_IMAGES}
{L_DISPLAY_INLINED}
{L_DISPLAY_INLINED_EXPLAIN}
{L_YES}   {L_NO}
{L_IMAGE_CREATE_THUMBNAIL}
{L_IMAGE_CREATE_THUMBNAIL_EXPLAIN}
{L_YES}   {L_NO}
{L_IMAGE_MIN_THUMB_FILESIZE}
{L_IMAGE_MIN_THUMB_FILESIZE_EXPLAIN}
{L_BYTES}
{L_USE_GD2}
{L_USE_GD2_EXPLAIN}
{L_YES}   {L_NO}
{L_IMAGE_IMAGICK_PATH}
{L_IMAGE_IMAGICK_PATH_EXPLAIN}
{L_MAX_IMAGE_SIZE}
{L_MAX_IMAGE_SIZE_EXPLAIN}
x
{L_IMAGE_LINK_SIZE}
{L_IMAGE_LINK_SIZE_EXPLAIN}
x
{S_HIDDEN_FIELDS}      
-
- - - - - - - -

{L_ATTACH_SETTINGS}

- -

{L_MANAGE_ATTACHMENTS_EXPLAIN}

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_ATTACH_SETTINGS}
{L_UPLOAD_DIRECTORY}
{L_UPLOAD_DIRECTORY_EXPLAIN}
{L_ATTACH_IMG_PATH}
{L_ATTACH_IMG_PATH_EXPLAIN}
{L_ATTACH_TOPIC_ICON}
{L_ATTACH_TOPIC_ICON_EXPLAIN}
{L_ATTACH_DISPLAY_ORDER}
{L_ATTACH_DISPLAY_ORDER_EXPLAIN}
- - - - - - - -
{L_DESC}
{L_ASC}
{L_ATTACH_FILESIZE_SETTINGS}
{L_MAX_FILESIZE_ATTACH}
{L_MAX_FILESIZE_ATTACH_EXPLAIN}
{S_FILESIZE}
{L_ATTACH_QUOTA}
{L_ATTACH_QUOTA_EXPLAIN}
{S_FILESIZE_QUOTA}
{L_MAX_FILESIZE_PM}
{L_MAX_FILESIZE_PM_EXPLAIN}
{S_FILESIZE_PM}
{L_DEFAULT_QUOTA_LIMIT}
{L_DEFAULT_QUOTA_LIMIT_EXPLAIN}
- - - - - - - - - -
{S_DEFAULT_UPLOAD_LIMIT} {L_UPLOAD_QUOTA} 
{S_DEFAULT_PM_LIMIT} {L_PM_QUOTA} 
-
{L_ATTACH_NUMBER_SETTINGS}
{L_MAX_ATTACHMENTS}
{L_MAX_ATTACHMENTS_EXPLAIN}
{L_MAX_ATTACHMENTS_PM}
{L_MAX_ATTACHMENTS_PM_EXPLAIN}
{L_ATTACH_OPTIONS_SETTINGS}
{L_DISABLE_MOD}
{L_DISABLE_MOD_EXPLAIN}
{L_YES}   {L_NO}
{L_PM_ATTACHMENTS}
{L_PM_ATTACHMENTS_EXPLAIN}
{L_YES}   {L_NO}
{S_HIDDEN_FIELDS}    
-
- - - - - - - -

{L_MANAGE_QUOTAS}

- -

{L_MANAGE_QUOTAS_EXPLAIN}

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_MANAGE_QUOTAS} -
{L_DESCRIPTION}{L_SIZE}{L_ADD_NEW}
{S_FILESIZE}
{S_HIDDEN_FIELDS}
{L_DESCRIPTION}{L_SIZE}{L_DELETE}
- - - - - - -
{L_VIEW}
-
{limit_row.S_FILESIZE}
-
- - - - -

{L_QUOTA_LIMIT_DESC}

- - - - - - - - - - - - - - -
- - - - - - - -
{L_ASSIGNED_USERS} - {L_UPLOAD_QUOTA}
- -
-
-     - - - - - - - - -
{L_ASSIGNED_GROUPS} - {L_UPLOAD_QUOTA}
- -
-
-     -
- - - - - - - -
{L_ASSIGNED_USERS} - {L_PM_QUOTA}
- -
-
-     - - - - - - - - -
{L_ASSIGNED_GROUPS} - {L_PM_QUOTA}
- -
-
- - - - - -
diff --git a/styles/templates/admin/admin_extensions.tpl b/styles/templates/admin/admin_extensions.tpl deleted file mode 100644 index 2abbd7592..000000000 --- a/styles/templates/admin/admin_extensions.tpl +++ /dev/null @@ -1,218 +0,0 @@ - - - -

{L_MANAGE_EXTENSIONS}

- -

{L_MANAGE_EXTENSIONS_EXPLAIN}

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_MANAGE_EXTENSIONS} -
 {L_EXPLANATION}  {L_EXTENSION}  {L_EXTENSION_GROUP}  {L_ADD_NEW} 
{S_ADD_GROUP_SELECT}
{S_HIDDEN_FIELDS}
 {L_EXPLANATION}  {L_EXTENSION}  {L_EXTENSION_GROUP}  {L_DELETE} 
{extension_row.EXTENSION}{extension_row.S_GROUP_SELECT}
- -
- -
- - - - - - - -{GROUP_PERMISSIONS_BOX} - -

{L_MANAGE_EXTENSION_GROUPS}

- -

{L_MANAGE_EXTENSION_GROUPS_EXPLAIN}

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_MANAGE_EXTENSION_GROUPS} -
 {L_EXTENSION_GROUP}  {L_SPECIAL_CATEGORY}  {L_ALLOWED}  {L_DOWNLOAD_MODE}  {L_UPLOAD_ICON}  {L_MAX_FILESIZE_ATTACH}  {L_ALLOWED_FORUMS}  {L_ADD_NEW} 
- - - - - -
 
-
{S_SELECT_CAT}{S_ADD_DOWNLOAD_MODE} {S_FILESIZE} 
 {L_EXTENSION_GROUP}  {L_SPECIAL_CATEGORY}  {L_ALLOWED}  {L_DOWNLOAD_MODE}  {L_UPLOAD_ICON}  {L_MAX_GROUPS_FILESIZE}  {L_ALLOWED_FORUMS}  {L_DELETE} 
- - - - - -
{grouprow.CAT_BOX}
-
{grouprow.S_SELECT_CAT}{grouprow.S_DOWNLOAD_MODE} {grouprow.S_FILESIZE}{L_EXT_GROUP_PERMISSIONS}
{grouprow.extensionrow.EXTENSION}{grouprow.extensionrow.EXPLANATION}      
- -
- -
- - - - - - - -

{L_GROUP_PERMISSIONS_TITLE}

- -

{L_GROUP_PERMISSIONS_EXPLAIN}

-
- - - - - - - -
-
- - - - - - - - - - -
{L_ALLOWED_FORUMS}
- -
 
-
-
-
- - - - - - - - - - -
{L_ADD_FORUMS}
- -
   
-
-
- - - - -
diff --git a/styles/templates/default/page_header.tpl b/styles/templates/default/page_header.tpl index f36e187c2..090fcd008 100644 --- a/styles/templates/default/page_header.tpl +++ b/styles/templates/default/page_header.tpl @@ -333,7 +333,6 @@ $(document).ready(function() { {L_CUR_UPLOADS} {L_SEARCH_DL_COMPLETE_DOWNLOADS} {L_SEARCH_DL_WILL_DOWNLOADS} - {L_WATCHED_TOPICS} diff --git a/styles/templates/default/usercp_topic_watch.tpl b/styles/templates/default/usercp_topic_watch.tpl deleted file mode 100644 index ed52e9ee1..000000000 --- a/styles/templates/default/usercp_topic_watch.tpl +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - -
-

{PAGE_TITLE}

- -
{PAGINATION}
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_FORUM}{L_TOPIC}{L_AUTHOR}{L_REPLIES}{L_LASTPOST}
- {watch.TOPIC_ICON} - - {watch.FORUM_TITLE} - {watch.TOPIC_TITLE} -
 [{ICON_GOTOPOST}{L_GOTO_SHORT} {watch.PAGINATION} ] -
{watch.AUTHOR}{watch.REPLIES} - {watch.LAST_POST}{ICON_NEWEST_REPLY} - {ICON_LATEST_REPLY} -
- {L_DEL_LIST_INFO}{MATCHES} -
diff --git a/styles/templates/default/viewtopic_attach_guest.tpl b/styles/templates/default/viewtopic_tor_guest.tpl similarity index 91% rename from styles/templates/default/viewtopic_attach_guest.tpl rename to styles/templates/default/viewtopic_tor_guest.tpl index a58aa5ec8..a3f6c2819 100644 --- a/styles/templates/default/viewtopic_attach_guest.tpl +++ b/styles/templates/default/viewtopic_tor_guest.tpl @@ -1,4 +1,3 @@ -
{L_DOWNLOAD} @@ -10,4 +9,3 @@

- diff --git a/terms.php b/terms.php index f2c2da064..0ccb29796 100644 --- a/terms.php +++ b/terms.php @@ -8,7 +8,6 @@ */ define('BB_SCRIPT', 'terms'); -define('BB_ROOT', './'); require __DIR__ . '/common.php'; require INC_DIR . '/bbcode.php';