diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php index 79dadc168b..e129930dee 100644 --- a/phpBB/adm/admin_attachments.php +++ b/phpBB/adm/admin_attachments.php @@ -14,14 +14,14 @@ if (!empty($setmodules)) { $filename = basename(__FILE__); - $module['POST']['ATTACHMENTS'] = ($auth->acl_get('a_attach')) ? "$filename$SID&mode=manage" : ''; + $module['POST']['ATTACHMENTS'] = ($auth->acl_get('a_attach')) ? "$filename$SID&mode=ext_groups" : ''; return; } define('IN_PHPBB', 1); // Include files -$phpbb_root_path = '../'; +$phpbb_root_path = './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); require('pagestart.' . $phpEx); include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); @@ -32,96 +32,15 @@ if (!$auth->acl_get('a_attach')) } $mode = request_var('mode', ''); -$config_sizes = array('max_filesize' => 'size', 'attachment_quota' => 'quota_size', 'max_filesize_pm' => 'pm_size'); - -foreach ($config_sizes as $cfg_key => $var) -{ - $$var = request_var($var, ''); -} - -$submit = (isset($_POST['submit'])) ? TRUE : FALSE; -$search_imagick = (isset($_POST['search_imagick'])) ? TRUE : FALSE; +$submit = (isset($_POST['submit'])) ? true : false; $error = $notify = array(); -// Pull all config data -$sql = 'SELECT * - FROM ' . CONFIG_TABLE; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $config_name = $row['config_name']; - $config_value = $row['config_value']; - - $default_config[$config_name] = $config_value; - $new[$config_name] = request_var($config_name, $default_config[$config_name]); - - foreach ($config_sizes as $cfg_key => $var) - { - if (empty($$var) && !$submit && $config_name == $cfg_key) - { - $$var = (intval($default_config[$config_name]) >= 1048576) ? 'mb' : ((intval($default_config[$config_name]) >= 1024) ? 'kb' : 'b'); - } - - if (!$submit && $config_name == $cfg_key) - { - $new[$config_name] = ($new[$config_name] >= 1048576) ? round($new[$config_name] / 1048576 * 100) / 100 : (($new[$config_name] >= 1024) ? round($new[$config_name] / 1024 * 100) / 100 : $new[$config_name]); - } - - if ($submit && $mode == 'manage' && $config_name == $cfg_key) - { - $old = $new[$config_name]; - $new[$config_name] = ($$var == 'kb') ? round($new[$config_name] * 1024) : (($$var == 'mb') ? round($new[$config_name] * 1048576) : $new[$config_name]); - } - } - - if ($submit && ($mode == 'manage' || $mode == 'cats')) - { - // Update Extension Group Filesizes - if ($config_name == 'max_filesize') - { - $old_size = (int) $default_config[$config_name]; - $new_size = (int) $new[$config_name]; - - if ($old_size != $new_size) - { - // check fir similar value of old_size in Extension Groups. If so, update these values. - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " - SET max_filesize = $new_size - WHERE max_filesize = $old_size"; - $db->sql_query($sql); - } - } - - set_config($config_name, $new[$config_name]); - - if (in_array($config_name, array('max_filesize', 'attachment_quota', 'max_filesize_pm'))) - { - $new[$config_name] = $old; - } - } -} - -if ($submit && ($mode == 'manage' || $mode == 'cats')) -{ - add_log('admin', 'LOG_ATTACH_CONFIG'); - $notify[] = $user->lang['ATTACH_CONFIG_UPDATED']; -} - // Adjust the Upload Directory. Relative or absolute, this is the question here. -$upload_dir = ($new['upload_dir'][0] == '/' || ($new['upload_dir'][0] != '/' && $new['upload_dir'][1] == ':')) ? $new['upload_dir'] : $phpbb_root_path . $new['upload_dir']; +$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir']; switch ($mode) { - case 'manage': - $l_title = 'ATTACHMENT_CONFIG'; - break; - - case 'cats': - $l_title = 'MANAGE_CATEGORIES'; - break; - case 'extensions': $l_title = 'MANAGE_EXTENSIONS'; break; @@ -140,50 +59,11 @@ switch ($mode) adm_page_header($user->lang[$l_title]); -// Search Imagick -if ($search_imagick) -{ - $imagick = ''; - - $exe = ((defined('PHP_OS')) && (preg_match('#win#i', PHP_OS))) ? '.exe' : ''; - - if (empty($_ENV['MAGICK_HOME'])) - { - $locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/'); - - foreach ($locations as $location) - { - if (file_exists($location . 'convert' . $exe) && is_executable($location . 'convert' . $exe)) - { - $imagick = str_replace('\\', '/', $location); - continue; - } - } - } - else - { - $imagick = str_replace('\\', '/', $_ENV['MAGICK_HOME']); - } - - $new['img_imagick'] = $imagick; -} - -// Check Settings -if ($submit && $mode == 'manage') -{ - test_upload($error, $upload_dir, false); -} - -if ($submit && $mode == 'cats') -{ - test_upload($error, $upload_dir . '/thumbs', true); -} if ($submit && $mode == 'extensions') { // Change Extensions ? $extension_change_list = (isset($_POST['extension_change_list'])) ? array_map('intval', $_POST['extension_change_list']) : array(); - $extension_explain_list = request_var('extension_explain_list', ''); $group_select_list = (isset($_POST['group_select'])) ? array_map('intval', $_POST['group_select']) : array(); // Generate correct Change List @@ -191,7 +71,6 @@ if ($submit && $mode == 'extensions') for ($i = 0; $i < count($extension_change_list); $i++) { - $extensions[$extension_change_list[$i]]['comment'] = $extension_explain_list[$i]; $extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i]; } @@ -202,12 +81,12 @@ if ($submit && $mode == 'extensions') while ($row = $db->sql_fetchrow($result)) { - if ($row['comment'] != $extensions[$row['extension_id']]['comment'] || $row['group_id'] != $extensions[$row['extension_id']]['group_id']) + if ($row['group_id'] != $extensions[$row['extension_id']]['group_id']) { - $sql = "UPDATE " . EXTENSIONS_TABLE . " - SET comment = '" . $db->sql_escape($extensions[$row['extension_id']]['comment']) . "', group_id = " . (int) $extensions[$row['extension_id']]['group_id'] . " - WHERE extension_id = " . $row['extension_id']; - $db->sql_query($sql); + $sql = 'UPDATE ' . EXTENSIONS_TABLE . ' + SET group_id = ' . (int) $extensions[$row['extension_id']]['group_id'] . ' + WHERE extension_id = ' . $row['extension_id']; + $db->sql_query($sql); add_log('admin', 'LOG_ATTACH_EXT_UPDATE', $row['extension']); } } @@ -240,9 +119,8 @@ if ($submit && $mode == 'extensions') // Add Extension ? $add_extension = strtolower(request_var('add_extension', '')); - $add_extension_explain = request_var('add_extension_explain', ''); $add_extension_group = request_var('add_group_select', 0); - $add = (isset($_POST['add_extension_check'])) ? TRUE : FALSE; + $add = (isset($_POST['add_extension_check'])) ? true : false; if ($add_extension != '' && $add) { @@ -263,8 +141,7 @@ if ($submit && $mode == 'extensions') { $sql_ary = array( 'group_id' => $add_extension_group, - 'extension' => $add_extension, - 'comment' => $add_extension_explain + 'extension' => $add_extension ); $db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); @@ -305,8 +182,8 @@ if ($submit && $mode == 'ext_groups') ); $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $group_sql) . ' - WHERE group_id = ' . $group_id; + SET ' . $db->sql_build_array('UPDATE', $group_sql) . " + WHERE group_id = $group_id"; $db->sql_query($sql); } @@ -348,8 +225,8 @@ if ($submit && $mode == 'ext_groups') $upload_icon = request_var('add_upload_icon', ''); $filesize = request_var('add_max_filesize', 0); $size_select = request_var('add_size_select', 'b'); - $is_allowed = (isset($_POST['add_allowed'])) ? TRUE : FALSE; - $add = (isset($_POST['add_extension_group_check'])) ? TRUE : FALSE; + $is_allowed = (isset($_POST['add_allowed'])) ? true : false; + $add = (isset($_POST['add_extension_group_check'])) ? true : false; if ($extension_group != '' && $add) { @@ -514,11 +391,7 @@ if (sizeof($notify)) '; foreach ($modes as $_mode) @@ -535,157 +408,6 @@ $s_select_mode .= ''; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lang['ATTACHMENT_SETTINGS']; ?>
lang['UPLOAD_DIR']; ?>:
lang['UPLOAD_DIR_EXPLAIN']; ?>
lang['DISPLAY_ORDER']; ?>:
lang['DISPLAY_ORDER_EXPLAIN']; ?>
- - - - - - - -
/> lang['DESCENDING']; ?>
/> lang['ASCENDING']; ?>
lang['ATTACH_MAX_FILESIZE']; ?>:
lang['ATTACH_MAX_FILESIZE_EXPLAIN']; ?>
lang['ATTACH_QUOTA']; ?>:
lang['ATTACH_QUOTA_EXPLAIN']; ?>
lang['ATTACH_MAX_PM_FILESIZE']; ?>:
lang['ATTACH_MAX_PM_FILESIZE_EXPLAIN']; ?>
lang['MAX_ATTACHMENTS'] ?>:
lang['MAX_ATTACHMENTS_EXPLAIN']; ?>
lang['MAX_ATTACHMENTS_PM'] ?>:
lang['MAX_ATTACHMENTS_PM_EXPLAIN']; ?>
lang['PM_ATTACH']; ?>:
lang['PM_ATTACH_EXPLAIN']; ?>
/> lang['YES']; ?>   /> lang['NO']; ?>
  
- 0 - ORDER BY cat_id'; - $result = $db->sql_query($sql); - - $s_assigned_groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $s_assigned_groups[$row['cat_id']][] = $row['group_name']; - } - $db->sql_freeresult($result); - - $display_inlined_yes = ($new['img_display_inlined']) ? 'checked="checked"' : ''; - $display_inlined_no = (!$new['img_display_inlined']) ? 'checked="checked"' : ''; - - $create_thumbnail_yes = ($new['img_create_thumbnail']) ? 'checked="checked"' : ''; - $create_thumbnail_no = (!$new['img_create_thumbnail']) ? 'checked="checked"' : ''; - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lang['SETTINGS_CAT_IMAGES']; ?>
lang['ASSIGNED_GROUP']; ?>: lang['NONE']); ?>
lang['DISPLAY_INLINED']; ?>:
lang['DISPLAY_INLINED_EXPLAIN']; ?>
/> lang['YES']; ?>   /> lang['NO']; ?>
lang['CREATE_THUMBNAIL']; ?>:
lang['CREATE_THUMBNAIL_EXPLAIN']; ?>
/> lang['YES']; ?>   /> lang['NO']; ?>
lang['MIN_THUMB_FILESIZE']; ?>:
lang['MIN_THUMB_FILESIZE_EXPLAIN']; ?>
lang['BYTES']; ?>
lang['IMAGICK_PATH']; ?>:
lang['IMAGICK_PATH_EXPLAIN']; ?>
lang['MAX_IMAGE_SIZE']; ?>:
lang['MAX_IMAGE_SIZE_EXPLAIN']; ?>
x
lang['IMAGE_LINK_SIZE']; ?>:
lang['IMAGE_LINK_SIZE_EXPLAIN']; ?>
x
    
- - -sql_query($sql); + $assigned_extensions = array(); while ($e_row = $db->sql_fetchrow($e_result)) { + $assigned_extensions[] = strtoupper($e_row['extension']); + } + $db->sql_freeresult($e_result); + ?> - - +  lang['ASSIGNED_EXTENSIONS'] . ' » ' . ((sizeof($assigned_extensions)) ? implode(', ', $assigned_extensions) : $user->lang['NONE']); ?> - @@ -892,54 +617,65 @@ if ($mode == 'extensions') ?> - + - + - - - - + + + - - - - + + + - + - - - - + + + -sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + if ($row = $db->sql_fetchrow($result)) { + $old_group_id = $row['group_id']; + do + { + $current_group_id = $row['group_id']; + if ($old_group_id != $current_group_id) + { +?> + + + + - - - - - + + + + sql_fetchrow($result)); } ?> - +
lang['MANAGE_EXTENSIONS']; ?>lang['MANAGE_EXTENSIONS']; ?>
 lang['COMMENT']; ?>  lang['EXTENSION']; ?>  lang['EXTENSION_GROUP']; ?>  lang['ADD_EXTENSION']; ?>  lang['EXTENSION']; ?>  lang['EXTENSION_GROUP']; ?>  lang['ADD_EXTENSION']; ?> 
 lang['COMMENT']; ?>  lang['EXTENSION']; ?>  lang['EXTENSION_GROUP']; ?>  lang['DELETE']; ?>  lang['EXTENSION']; ?>  lang['EXTENSION_GROUP']; ?>  lang['DELETE']; ?> 
    
lang['DIRECTORY_DOES_NOT_EXIST'], $upload_dir); - } - - if (!count($error) && !is_dir($upload_dir)) - { - $error[] = sprintf($user->lang['DIRECTORY_IS_NOT_A_DIR'], $upload_dir); - } - - if (!count($error)) - { - if (!($fp = @fopen($upload_dir . '/0_000000.000', 'w'))) - { - $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITEABLE'], $new['upload_dir']); - } - else - { - @fclose($fp); - @unlink($upload_dir . '/0_000000.000'); - } - } -} - -// Generate select form -function size_select($select_name, $size_compare) -{ - global $user; - - $size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']); - $size_types = array('b', 'kb', 'mb'); - - $select_field = ''; - - return ($select_field); -} - // Build Select for category items function category_select($select_name, $group_id = FALSE) {