diff --git a/phpBB/adm/admin_board.php b/phpBB/adm/admin_board.php index de3ef0ce45..0358c144ba 100644 --- a/phpBB/adm/admin_board.php +++ b/phpBB/adm/admin_board.php @@ -14,14 +14,15 @@ if (!empty($setmodules)) { $filename = basename(__FILE__); - $module['GENERAL']['COOKIE_SETTINGS'] = ($auth->acl_get('a_cookies')) ? "$filename$SID&mode=cookie" : ''; + $module['GENERAL']['ATTACHMENT_SETTINGS'] = ($auth->acl_get('a_attach')) ? "$filename$SID&mode=attach" : ''; + $module['GENERAL']['AUTH_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&mode=auth" : ''; + $module['GENERAL']['AVATAR_SETTINGS'] = ($auth->acl_get('a_board')) ? "$filename$SID&mode=avatar" : ''; $module['GENERAL']['BOARD_DEFAULTS'] = ($auth->acl_get('a_defaults')) ? "$filename$SID&mode=default" : ''; $module['GENERAL']['BOARD_SETTINGS'] = ($auth->acl_get('a_board')) ? "$filename$SID&mode=setting" : ''; - $module['GENERAL']['AVATAR_SETTINGS'] = ($auth->acl_get('a_board')) ? "$filename$SID&mode=avatar" : ''; + $module['GENERAL']['COOKIE_SETTINGS'] = ($auth->acl_get('a_cookies')) ? "$filename$SID&mode=cookie" : ''; $module['GENERAL']['EMAIL_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&mode=email" : ''; - $module['GENERAL']['SERVER_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&mode=server" : ''; - $module['GENERAL']['AUTH_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&mode=auth" : ''; $module['GENERAL']['LOAD_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&mode=load" : ''; + $module['GENERAL']['SERVER_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&mode=server" : ''; $module['USER']['KARMA_SETTINGS'] = ($auth->acl_get('a_user')) ? "$filename$SID&mode=karma" : ''; return; } @@ -33,12 +34,16 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1); require('pagestart.' . $phpEx); // Get mode -$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; +$mode = request_var('mode', ''); $submit = (isset($_POST['submit'])) ? true : false; // Check permissions/set title switch ($mode) { + case 'attach': + $l_title = 'ATTACHMENT_SETTINGS'; + $which_auth = 'a_attach'; + break; case 'cookie': $l_title = 'COOKIE_SETTINGS'; $which_auth = 'a_cookies'; @@ -85,6 +90,13 @@ if (!$auth->acl_get($which_auth)) trigger_error($user->lang['NO_ADMIN']); } +$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, ''); +} +$error = array(); + // Pull all config data $sql = 'SELECT * FROM ' . CONFIG_TABLE; @@ -102,16 +114,77 @@ while ($row = $db->sql_fetchrow($result)) $new['bump_interval'] = request_var('bump_interval', 0) . request_var('bump_type', ''); } - if ($submit) + if ($mode == 'attach') { - set_config($config_name, $new[$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 && $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) + { + // 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 for 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; + } + } + } + else + { + if ($submit) + { + set_config($config_name, $new[$config_name]); + } } } if ($submit) { add_log('admin', 'LOG_' . strtoupper($mode) . '_CONFIG'); - trigger_error($user->lang['CONFIG_UPDATED']); + + if ($mode == 'attach') + { + // Check Settings + test_upload($error, $new['upload_dir'], false); + test_upload($error, $new['upload_dir'] . '/thumbs', true); + } + + if (!sizeof($error)) + { + trigger_error($user->lang['CONFIG_UPDATED']); + } } adm_page_header($user->lang[$l_title]); @@ -122,6 +195,17 @@ adm_page_header($user->lang[$l_title]);

lang[$l_title . '_EXPLAIN']; ?>

+ +

lang['WARNING']; ?>

+ +

', $error); ?>

+ +
" method="post"> @@ -131,6 +215,129 @@ adm_page_header($user->lang[$l_title]); // Output relevant page switch ($mode) { + case 'attach': + + include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + + if (isset($_POST['search_imagick'])) + { + $new['img_imagick'] = search_imagemagick(); + } + + $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); + + $display_order_yes = ($new['display_order']) ? 'checked="checked"' : ''; + $display_order_no = (!$new['display_order']) ? 'checked="checked"' : ''; + + $sql = 'SELECT group_name, cat_id + FROM ' . EXTENSION_GROUPS_TABLE . ' + WHERE cat_id > 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"' : ''; + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '.*', 'USERNAME_ALPHA_ONLY' => '[/w]+', 'USERNAME_ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+'); $user_char_options = ''; @@ -322,6 +504,10 @@ switch ($mode) + + + + @@ -348,7 +534,7 @@ switch ($mode) - + - +
lang[$l_title]; ?>
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_PM'] ?>:
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
lang['ALLOW_ATTACHMENTS']; ?>: /> lang['YES']; ?>   /> lang['NO']; ?>
lang['ALLOW_PM_ATTACHMENTS']; ?>: /> lang['YES']; ?>   /> lang['NO']; ?>
lang['ALLOW_HTML']; ?>: /> lang['YES']; ?>   /> lang['NO']; ?>
lang['ALLOW_NO_CENSORS']; ?>:
lang['ALLOW_NO_CENSORS_EXPLAIN']; ?>
/> lang['YES']; ?>   /> lang['NO']; ?> /> lang['YES']; ?>   /> lang['NO']; ?>
    lang['SEARCH_IMAGICK'] . '" class="btnlite" />  ' : ''; ?>
@@ -794,4 +980,69 @@ switch ($mode) adm_page_footer(); +// Functions + +// Search Imagick +function search_imagemagick() +{ + $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']); + } + + return $imagick; +} + +// Test Settings +function test_upload(&$error, $upload_dir, $create_directory = false) +{ + global $user, $phpbb_root_path; + + // Adjust the Upload Directory. Relative or absolute, this is the question here. + $real_upload_dir = $upload_dir; + $upload_dir = ($upload_dir{0} == '/' || ($upload_dir{0} != '/' && $upload_dir{1} == ':')) ? $upload_dir : $phpbb_root_path . $upload_dir; + + // Does the target directory exist, is it a directory and writeable. + if ($create_directory) + { + if (!file_exists($upload_dir)) + { + @mkdir($upload_dir, 0755); + @chmod($upload_dir, 0777); + } + } + + if (!file_exists($upload_dir)) + { + $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $real_upload_dir); + } + + if (!count($error) && !is_dir($upload_dir)) + { + $error[] = sprintf($user->lang['DIRECTORY_IS_NOT_A_DIR'], $real_upload_dir); + } + + if (!count($error) && !is_writable($upload_dir)) + { + $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITEABLE'], $real_upload_dir); + } +} + ?> \ No newline at end of file