diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php
deleted file mode 100644
index 274b673bb..000000000
--- a/admin/admin_attach_cp.php
+++ /dev/null
@@ -1,556 +0,0 @@
-';
-
-for($i = 0; $i < count($view_types_text); $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']) ) ? TRUE : FALSE;
-$delete = ( isset($_POST['delete']) ) ? TRUE : FALSE;
-$delete_id_list = get_var('delete_id_list', array(0));
-
-$confirm = isset($_POST['confirm']);
-
-if ($confirm && sizeof($delete_id_list) > 0)
-{
- $attachments = array();
-
- delete_attachment(0, $delete_id_list);
-}
-else if ($delete && sizeof($delete_id_list) > 0)
-{
- // Not confirmed, show confirmation message
- $hidden_fields = '';
- $hidden_fields .= '';
- $hidden_fields .= '';
- $hidden_fields .= '';
- $hidden_fields .= '';
-
- for ($i = 0; $i < sizeof($delete_id_list); $i++)
- {
- $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; $i < count($attach_change_list); $i++)
- {
- $attachments['_' . $attach_change_list[$i]]['comment'] = $attach_comment_list[$i];
- $attachments['_' . $attach_change_list[$i]]['download_count'] = $attach_download_count_list[$i];
- }
-
- $sql = 'SELECT *
- 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 = '';
- while ($row = DB()->sql_fetchrow($result))
- { //sf
- $s_forums .= '';
-
- if( empty($list_cat[$row['cat_id']]) )
- {
- $list_cat[$row['cat_id']] = $row['cat_title'];
- }
- }
-
- 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']) ? TRUE : FALSE;
-
- $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 = " . intval($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 = " . intval($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[] = intval($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 (sizeof($attachments) > 0)
- {
- for ($i = 0; $i < sizeof($attachments); $i++)
- {
- $delete_box = '';
-
- for ($j = 0; $j < count($delete_id_list); $j++)
- {
- if ($delete_id_list[$j] == $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 = array();
-
- $sql = "SELECT *
- FROM " . BB_ATTACHMENTS . "
- WHERE attach_id = " . intval($attachments[$i]['attach_id']);
-
- if (!($result = DB()->sql_query($sql)))
- {
- bb_die('Could not query attachments #3');
- }
-
- $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 = " . intval($ids[$j]['post_id']) . " AND p.topic_id = t.topic_id
- GROUP BY t.topic_id, t.topic_title";
-
- if (!($result = DB()->sql_query($sql)))
- {
- bb_die('Could not query topic');
- }
-
- $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 . DOWNLOAD_URL . $attachments[$i]['attach_id'],
- ));
-
- }
- }
-
- if (!$search_based && !$user_based)
- {
- if ($total_attachments == 0)
- {
- $sql = "SELECT attach_id FROM " . BB_ATTACHMENTS_DESC;
-
- if (!($result = DB()->sql_query($sql)))
- {
- bb_die('Could not query attachment description table');
- }
-
- $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');
\ No newline at end of file
diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php
deleted file mode 100644
index 3d0d93356..000000000
--- a/admin/admin_attachments.php
+++ /dev/null
@@ -1,719 +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;
- }
- else if ($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 (preg_match('/convert/i', $imagick))
- {
- return true;
- }
- else if ($imagick != 'none')
- {
- if (!preg_match('/WIN/i', PHP_OS))
- {
- $retval = @exec('whereis convert');
- $paths = explode(' ', $retval);
-
- if (is_array($paths))
- {
- for ( $i=0; $i < sizeof($paths); $i++)
- {
- $path = basename($paths[$i]);
-
- if ($path == 'convert')
- {
- $imagick = $paths[$i];
- }
- }
- }
- }
- else if (preg_match('/WIN/i', PHP_OS))
- {
- $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', 'w')) )
- {
- $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')
-{
- $yes_no_switches = array('disable_mod', 'allow_pm_attach', 'display_order');
-
- for ($i = 0; $i < sizeof($yes_no_switches); $i++)
- {
- eval("\$" . $yes_no_switches[$i] . "_yes = ( \$new_attach['" . $yes_no_switches[$i] . "'] != '0' ) ? 'checked=\"checked\"' : '';");
- eval("\$" . $yes_no_switches[$i] . "_no = ( \$new_attach['" . $yes_no_switches[$i] . "'] == '0' ) ? 'checked=\"checked\"' : '';");
- }
-
- $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', intval(trim($new_attach['default_upload_quota']))),
- 'S_DEFAULT_PM_LIMIT' => default_quota_limit_select('default_pm_quota', intval(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' => $disable_mod_yes,
- 'DISABLE_MOD_NO' => $disable_mod_no,
- 'PM_ATTACH_YES' => $allow_pm_attach_yes,
- 'PM_ATTACH_NO' => $allow_pm_attach_no,
- 'DISPLAY_ORDER_ASC' => $display_order_yes,
- 'DISPLAY_ORDER_DESC' => $display_order_no,
- ));
-}
-
-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; $i < sizeof($row); $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)) )
- {
- @mkdir($upload_dir, 0755);
- @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', 'w')) )
- {
- $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; $i < sizeof($quota_change_list); $i++)
- {
- $filesize_list[$i] = ( $size_select_list[$i] == 'kb' ) ? round($filesize_list[$i] * 1024) : ( ($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i] );
-
- $sql = 'UPDATE ' . BB_QUOTA_LIMITS . "
- SET quota_desc = '" . attach_mod_sql_escape($quota_desc_list[$i]) . "', quota_limit = " . (int) $filesize_list[$i] . "
- WHERE quota_limit_id = " . (int) $quota_change_list[$i];
-
- if (!(DB()->sql_query($sql)))
- {
- 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;
- }
- else if ( $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; $i < sizeof($rows); $i++)
- {
- $size_format = ($rows[$i]['quota_limit'] >= 1048576) ? 'mb' : ( ($rows[$i]['quota_limit'] >= 1024) ? 'kb' : 'b' );
-
- if ( $rows[$i]['quota_limit'] >= 1048576)
- {
- $rows[$i]['quota_limit'] = round($rows[$i]['quota_limit'] / 1048576 * 100) / 100;
- }
- else if($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"a_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'],
- ));
- }
- else if ($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'],
- ));
- }
- else if ($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');
\ No newline at end of file
diff --git a/admin/admin_extensions.php b/admin/admin_extensions.php
deleted file mode 100644
index d36b997c7..000000000
--- a/admin/admin_extensions.php
+++ /dev/null
@@ -1,780 +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');
-
-// Check if the language got included
-if (!isset($lang['TEST_SETTINGS_SUCCESSFUL']))
-{
- // include_once is used within the function
- include_attach_lang();
-}
-
-// 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', '');
-
-$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; $i < sizeof($extension_change_list); $i++)
- {
- $extensions['_' . $extension_change_list[$i]]['comment'] = $extension_explain_list[$i];
- $extensions['_' . $extension_change_list[$i]]['group_id'] = intval($group_select_list[$i]);
- }
-
- $sql = 'SELECT * FROM ' . BB_EXTENSIONS . ' ORDER BY ext_id';
- if (!($result = DB()->sql_query($sql)))
- {
- 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; $i < sizeof($extension_row); $i++)
- {
- if ($extension_row[$i]['comment'] != $extensions['_' . $extension_row[$i]['ext_id']]['comment'] || intval($extension_row[$i]['group_id']) != intval($extensions['_' . $extension_row[$i]['ext_id']]['group_id']))
- {
- $sql_ary = array(
- 'comment' => (string) $extensions['_' . $extension_row[$i]['ext_id']]['comment'],
- 'group_id' => (int) $extensions['_' . $extension_row[$i]['ext_id']]['group_id']
- );
-
- $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, 'group_name', 'ASC');
-
- 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();
-
- for ($i = 0; $i < sizeof($group_allowed_list); $i++)
- {
- for ($j = 0; $j < sizeof($group_change_list); $j++)
- {
- if ($group_allowed_list[$i] == $group_change_list[$j])
- {
- $allowed_list[$j] = 1;
- }
- }
- }
-
- for ($i = 0; $i < sizeof($group_change_list); $i++)
- {
- $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;
- }
- else if ( $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' => ( isset($submit) ) ? @$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;
- }
- else if($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);
-
- $add_forum = (isset($_POST['add_forum'])) ? TRUE : FALSE;
- $delete_forum = (isset($_POST['del_forum'])) ? TRUE : FALSE;
-
- 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;
-
- for ($i = 0; $i < sizeof($add_forums_list); $i++)
- {
- if ($add_forums_list[$i] == 0)
- {
- $add_all_forums = TRUE;
- }
- }
-
- // If we add ALL FORUMS, we are able to overwrite the Permissions
- if ($add_all_forums)
- {
- $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 = ' . intval($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
- for ($i = 0; $i < sizeof($add_forums_list); $i++)
- {
- if (!in_array($add_forums_list[$i], $auth_p))
- {
- $auth_p[] = $add_forums_list[$i];
- }
- }
-
- $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 = ' . intval($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
- for ($i = 0; $i < sizeof($auth_p2); $i++)
- {
- if (!in_array($auth_p2[$i], $delete_forums_list))
- {
- $auth_p[] = $auth_p2[$i];
- }
- }
-
- $auth_bitstream = (sizeof($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 = ' . intval($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; $i < sizeof($forum_perm); $i++)
- {
- $template->assign_block_vars('allow_option_values', array(
- 'VALUE' => $forum_perm[$i]['forum_id'],
- 'OPTION' => htmlCHR($forum_perm[$i]['forum_name']))
- );
- }
-
- $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[intval($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 (sizeof($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');
\ No newline at end of file
diff --git a/admin/admin_groups.php b/admin/admin_groups.php
index ade36db3a..8faed407e 100644
--- a/admin/admin_groups.php
+++ b/admin/admin_groups.php
@@ -12,8 +12,6 @@ require(INC_DIR .'functions_group.php');
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? intval($_REQUEST[POST_GROUPS_URL]) : 0;
$mode = isset($_REQUEST['mode']) ? strval($_REQUEST['mode']) : '';
-attachment_quota_settings('group', isset($_POST['group_update']), $mode);
-
if (!empty($_POST['edit']) || !empty($_POST['new']))
{
if (!empty($_POST['edit']))
diff --git a/admin/pagestart.php b/admin/pagestart.php
index 40449b461..69c2bce79 100644
--- a/admin/pagestart.php
+++ b/admin/pagestart.php
@@ -5,8 +5,6 @@ define('IN_FORUM', true);
define('IN_ADMIN', true);
require(BB_ROOT .'common.php');
-require(ATTACH_DIR .'attachment_mod.php');
-require(ATTACH_DIR .'includes/functions_admin.php');
require_once(INC_DIR .'functions_admin.php');
$user->session_start();
diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql
index 91dec0104..efead9c2a 100644
--- a/install/sql/mysql.sql
+++ b/install/sql/mysql.sql
@@ -540,7 +540,6 @@ CREATE TABLE IF NOT EXISTS `bb_cron` (
-- ----------------------------
-- Records of bb_cron
-- ----------------------------
-INSERT INTO `bb_cron` VALUES ('', '1', 'Attach maintenance', 'attach_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0', '1', '0');
INSERT INTO `bb_cron` VALUES ('', '1', 'Board maintenance', 'board_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0', '1', '0');
INSERT INTO `bb_cron` VALUES ('', '1', 'Prune forums', 'prune_forums.php', 'daily', '', '05:00:00', '50', '', '', '', '1', '', '0', '1', '0');
INSERT INTO `bb_cron` VALUES ('', '1', 'Prune topic moved stubs', 'prune_topic_moved.php', 'daily', '', '05:00:00', '60', '', '', '', '1', '', '0', '1', '0');
diff --git a/install/upgrade/changes.txt b/install/upgrade/changes.txt
index e3b97aa58..6ac007756 100644
--- a/install/upgrade/changes.txt
+++ b/install/upgrade/changes.txt
@@ -57,3 +57,4 @@ INSERT INTO `bb_cron` VALUES ('', '1', 'Accrual seedbonus', 'tr_seed_bonus.php',
// 2.1.6
DROP TABLE IF EXISTS `bb_ads`;
DELETE FROM `bb_config` WHERE `config_name` = 'active_ads';
+DELETE FROM `bb_cron` WHERE `cron_script` = 'attach_maintenance.php';
\ No newline at end of file
diff --git a/library/includes/cron/jobs/attach_maintenance.php b/library/includes/cron/jobs/attach_maintenance.php
deleted file mode 100644
index 1274b35bd..000000000
--- a/library/includes/cron/jobs/attach_maintenance.php
+++ /dev/null
@@ -1,224 +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 = join(',', $files);
- DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
- $files = array();
- $f_len = 0;
- }
- }
- if ($files = join(',', $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 = join(',', $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 = join(',', $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 = join(',', $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 = join(',', $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);
\ No newline at end of file
diff --git a/styles/js/bbcode.js b/styles/js/bbcode.js
index 9b8ddcb4c..7e5cf1c90 100644
--- a/styles/js/bbcode.js
+++ b/styles/js/bbcode.js
@@ -177,7 +177,6 @@ BBCode.prototype = {
// Available key combinations and these interpretaions for BB are
// TAB - Insert TAB char
// CTRL-TAB - Next form field (usual TAB)
- // SHIFT-ALT-PAGEUP - Add an Attachment
// ALT-ENTER - Preview
// CTRL-ENTER - Submit
onKeyPress: function(e, type) {
@@ -210,8 +209,6 @@ BBCode.prototype = {
// Hot keys
var form = this.textarea.form;
var submitter = null;
- if (e.keyCode == this.VK_PAGE_UP && e.shiftKey && !e.ctrlKey && e.altKey)
- submitter = form.add_attachment_box;
if (e.keyCode == this.VK_ENTER &&!e.shiftKey && !e.ctrlKey && e.altKey)
submitter = form.preview;
if (e.keyCode == this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey)
diff --git a/styles/templates/admin/admin_attach_cp.tpl b/styles/templates/admin/admin_attach_cp.tpl
deleted file mode 100644
index 0336213d9..000000000
--- a/styles/templates/admin/admin_attach_cp.tpl
+++ /dev/null
@@ -1,256 +0,0 @@
-
{L_CONTROL_PANEL_EXPLAIN}
-{L_MANAGE_CATEGORIES_EXPLAIN}
-{L_MANAGE_ATTACHMENTS_EXPLAIN}
-{L_MANAGE_QUOTAS_EXPLAIN}
-
-
|
- - - | -
-
|
- ||||
- - | -||||||
-
|
- - - | -
-
|
-
{L_MANAGE_EXTENSIONS_EXPLAIN}
-{L_MANAGE_EXTENSION_GROUPS_EXPLAIN}
-{L_GROUP_PERMISSIONS_EXPLAIN}
-- - | -
- - | -