From 3a4e4374dc3a788b5ccafa882da92421fd301866 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 29 Apr 2003 20:06:25 +0000 Subject: further work on the attachment panel... and see how plain those icons are... these are the correct ones to rip ;) Hopefully someone will make some nice upload icons. :) git-svn-id: file:///svn/phpbb/trunk@3959 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_attachments.php | 530 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 507 insertions(+), 23 deletions(-) (limited to 'phpBB/adm/admin_attachments.php') diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php index 39e1bb8c3f..a48c62fba7 100644 --- a/phpBB/adm/admin_attachments.php +++ b/phpBB/adm/admin_attachments.php @@ -121,7 +121,7 @@ while ($row = $db->sql_fetchrow($result)) if ($submit && ($mode == 'manage' || $mode == 'cats')) { - add_log('admin', 'LOG_SETTING_CONFIG'); + add_log('admin', 'LOG_ATTACH_CONFIG'); $notify = TRUE; $notify_msg = $user->lang['ATTACH_CONFIG_UPDATED']; } @@ -152,6 +152,9 @@ switch ($mode) case 'cats': $l_title = 'MANAGE_CATEGORIES'; break; + + case 'ext_groups': + $l_title = 'EXTENSION_GROUPS_TITLE'; } // Temporary Language Variables @@ -214,6 +217,162 @@ if ($submit && $mode == 'cats') test_upload($error, $error_msg, $upload_dir, $new['ftp_path'] . '/thumbs', $new['allow_ftp_upload'], true); } +if ($submit && $mode == 'ext_groups') +{ + // Change Extension Groups ? + $group_change_list = ( isset($_POST['group_change_list']) ) ? $_POST['group_change_list'] : array(); + $extension_group_list = ( isset($_POST['extension_group_list']) ) ? $_POST['extension_group_list'] : array(); + $group_allowed_list = ( isset($_POST['allowed_list']) ) ? $_POST['allowed_list'] : array(); + $download_mode_list = ( isset($_POST['download_mode_list']) ) ? $_POST['download_mode_list'] : array(); + $category_list = ( isset($_POST['category_list']) ) ? $_POST['category_list'] : array(); + $upload_icon_list = ( isset($_POST['upload_icon_list']) ) ? $_POST['upload_icon_list'] : array(); + $filesize_list = ( isset($_POST['max_filesize_list']) ) ? $_POST['max_filesize_list'] : array(); + $size_select_list = ( isset($_POST['size_select_list']) ) ? $_POST['size_select_list'] : array(); + + $allowed_list = array(); + + for ($i = 0; $i < count($group_allowed_list); $i++) + { + for ($j = 0; $j < count($group_change_list); $j++) + { + if ($group_allowed_list[$i] == $group_change_list[$j]) + { + $allowed_list[$j] = '1'; + } + } + } + + for ($i = 0; $i < count($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] ); + + $group_sql = array( + 'group_name' => $extension_group_list[$i], + 'cat_id' => $category_list[$i], + 'allow_group' => $allowed, + 'download_mode' => $download_mode_list[$i], + 'upload_icon' => ($upload_icon_list[$i] == 'no_image') ? '' : $upload_icon_list[$i], + 'max_filesize' => $filesize_list[$i] + ); + + $sql = "UPDATE " . EXTENSION_GROUPS_TABLE . " SET " . $db->sql_build_array('UPDATE', $group_sql) . " WHERE group_id = " . $group_change_list[$i]; + $db->sql_query($sql); + } + + // Delete Extension Groups + $group_id_list = ( isset($_POST['group_id_list']) ) ? $_POST['group_id_list'] : array(); + + if (count($group_id_list)) + { + $l_group_list = ''; + + $sql = "SELECT group_name + FROM " . EXTENSION_GROUPS_TABLE . " + WHERE group_id IN (" . implode(', ', $group_id_list) . ")"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $l_group_list .= (($l_group_list != '') ? ', ' : '') . $row['group_name']; + } + $db->sql_freeresult($result); + + $sql = "DELETE + FROM " . EXTENSION_GROUPS_TABLE . " + WHERE group_id IN (" . implode(', ', $group_id_list) . ")"; + $db->sql_query($sql); + + // Set corresponding Extensions to a pending Group + $sql = "UPDATE " . EXTENSIONS_TABLE . " + SET group_id = 0 + WHERE group_id IN (" . implode(', ', $group_id_list) . ")"; + $db->sql_query($sql); + + add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $l_group_list); + } + + // Add Extensions Group ? + $extension_group = ( isset($_POST['add_extension_group']) ) ? trim(strip_tags($_POST['add_extension_group'])) : ''; + $download_mode = ( isset($_POST['add_download_mode']) ) ? $_POST['add_download_mode'] : ''; + $cat_id = ( isset($_POST['add_category']) ) ? $_POST['add_category'] : ''; + $upload_icon = ( isset($_POST['add_upload_icon']) ) ? $_POST['add_upload_icon'] : ''; + $filesize = ( isset($_POST['add_max_filesize']) ) ? $_POST['add_max_filesize'] : ''; + $size_select = ( isset($_POST['add_size_select']) ) ? $_POST['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 " . EXTENSION_GROUPS_TABLE; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if ($row['group_name'] == $extension_group) + { + $error = TRUE; + if (isset($error_msg)) + { + $error_msg .= '
'; + } + $error_msg .= sprintf($user->lang['EXTENSION_GROUP_EXIST'], $extension_group); + } + } + $db->sql_freeresult($result); + + if (!$error) + { + $filesize = ($size_select == 'kb') ? round($filesize * 1024) : (($size_select == 'mb') ? round($filesize * 1048576) : $filesize); + + $group_sql = array( + 'group_name' => $extension_group, + 'cat_id' => $cat_id, + 'allow_group' => $is_allowed, + 'download_mode' => $download_mode, + 'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon, + 'max_filesize' => $filesize + ); + + $sql = "INSERT INTO " . EXTENSION_GROUPS_TABLE . " " . $db->sql_build_array('INSERT', $group_sql); + $db->sql_query($sql); + + add_log('admin', 'LOG_ATTACH_EXTGROUP_ADD', $extension_group); + } + } + + $sql = "SELECT e.extension, g.* + FROM " . EXTENSIONS_TABLE . " e, " . EXTENSION_GROUPS_TABLE . " g + WHERE e.group_id = g.group_id + AND g.allow_group = 1"; + $result = $db->sql_query($sql); + + $extensions = array(); + while ($row = $db->sql_fetchrow($result)) + { + $extension = strtolower(trim($row['extension'])); + + $extensions['_allowed_'][] = $extension; + $extensions[$extension]['display_cat'] = intval($row['cat_id']); + $extensions[$extension]['download_mode'] = intval($row['download_mode']); + $extensions[$extension]['upload_icon'] = trim($row['upload_icon']); + $extensions[$extension]['max_filesize'] = intval($row['max_filesize']); + } + $db->sql_freeresult($result); + + $cache->destroy('extensions'); + $cache->put('extensions', $extensions); + + if (!$error) + { + $notify = true; + $notify_msg = $user->lang['EXTENSION_GROUPS_UPDATED']; + } +} + ?>

lang[$l_title]; ?>

@@ -242,7 +401,7 @@ else if ($notify)    - - -
- +      - - -
+ lang['BYTES'], $user->lang['KB'], $user->lang['MB']); - $size_types = array('b', 'kb', 'mb'); + $imglist = filelist($phpbb_root_path . $img_path, ''); - $select_field = ''; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + // Format the filesize + if ($row['max_filesize'] == 0) + { + $row['max_filesize'] = intval($config['max_filesize']); + } + + $size_format = ($row['max_filesize'] >= 1048576) ? 'mb' : ( ($row['max_filesize'] >= 1024) ? 'kb' : 'b' ); + + if ($row['max_filesize'] >= 1048576) + { + $row['max_filesize'] = round($row['max_filesize'] / 1048576 * 100) / 100; + } + else if($row['max_filesize'] >= 1024) + { + $row['max_filesize'] = round($row['max_filesize'] / 1024 * 100) / 100; + } + + $s_allowed = ($row['allow_group'] == 1) ? 'checked="checked"' : ''; + $edit_img = ($row['upload_icon'] != '') ? $row['upload_icon'] : ''; + + $filename_list = ''; + $no_image_select = false; + foreach ($imglist as $img) + { + $img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file']; + + if ($edit_img == '') + { + $no_image_select = true; + $selected = ''; + } + else + { + $selected = ($edit_img == $img) ? ' selected="selected"' : ''; + } + + $filename_list .= ''; + } +?> + + + + + + + + + + +sql_query($sql); + + while ($e_row = $db->sql_fetchrow($e_result)) + { +?> + + + + + + + + +
lang['EXTENSION_GROUPS_TITLE']; ?>
 lang['EXTENSION_GROUP']; ?>  lang['SPECIAL_CATEGORY']; ?>  lang['ALLOWED']; ?>  lang['DOWNLOAD_MODE']; ?>  lang['UPLOAD_ICON']; ?>  lang['MAX_EXTGROUP_FILESIZE']; ?>  lang['ADD']; ?> 
+ + + + + +
 
+
   
 lang['EXTENSION_GROUP']; ?>  lang['SPECIAL_CATEGORY']; ?>  lang['ALLOWED']; ?>  lang['DOWNLOAD_MODE']; ?>  lang['UPLOAD_ICON']; ?>  lang['MAX_EXTGROUP_FILESIZE']; ?>  lang['DELETE']; ?> 
+ + + + + +
" class="gen">
+
/>    
  
+ + + + +
+ +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 = -1) +{ + global $db, $user; + + $types = array( + NONE_CAT => $user->lang['NONE'], + IMAGE_CAT => $user->lang['CAT_IMAGES'], + WM_CAT => $user->lang['CAT_WM_FILES'], + RM_CAT => $user->lang['CAT_RM_FILES'] + ); + + if ($group_id != -1) + { + $sql = "SELECT cat_id + FROM " . EXTENSION_GROUPS_TABLE . " + WHERE group_id = " . intval($group_id); + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + $cat_type = NONE_CAT; + } + else + { + $cat_type = $row['cat_id']; + } + + $db->sql_freeresult($result); + } + else + { + $cat_type = NONE_CAT; + } + + $group_select = ''; + + return($group_select); +} + +// Build select for download modes + +function download_select($select_name, $group_id = -1) +{ + global $db, $user; + + $types = array( + INLINE_LINK => $user->lang['MODE_INLINE'], + PHYSICAL_LINK => $user->lang['MODE_PHYSICAL'] + ); + + if ($group_id != -1) + { + $sql = "SELECT download_mode + FROM " . EXTENSION_GROUPS_TABLE . " + WHERE group_id = " . intval($group_id); + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + $download_mode = INLINE_LINK; + } + else + { + $download_mode = $row['download_mode']; + } + + $db->sql_freeresult($result); + } + else + { + $download_mode = INLINE_LINK; + } + + $group_select = ''; + + return($group_select); +} + // Get supported Image types function get_supported_image_types() { @@ -657,4 +1114,31 @@ function get_supported_image_types() return ($types); } +function filelist($rootdir, $dir = '', $type = 'gif|jpg|png') +{ + static $images = array(); + + $dh = opendir($rootdir . $dir); + + while ($fname = readdir($dh)) + { + if (is_file($rootdir . $dir . '/' . $fname) && + preg_match('#\.' . $type . '$#i', $fname) && + filesize($rootdir . $dir . '/' . $fname)) + { + $images[] = array('path' => $dir, 'file' => $fname); + } + else if ($fname != '.' && $fname != '..' && + !is_file($rootdir . $dir . '/' . $fname) && + !is_link($rootdir . $dir . '/' . $fname)) + { + filelist($rootdir, $dir . '/'. $fname, $type); + } + } + + closedir($dh); + + return $images; +} + ?> \ No newline at end of file -- cgit v1.2.1