⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acp_attachments.php

📁 通过基于Windows的图形化界面
💻 PHP
📖 第 1 页 / 共 3 页
字号:
					if (!sizeof($error))					{						// Ok, build the update/insert array						$upload_icon	= request_var('upload_icon', 'no_image');						$size_select	= request_var('size_select', 'b');						$forum_select	= request_var('forum_select', false);						$allowed_forums	= request_var('allowed_forums', array(0));						$allow_in_pm	= (isset($_POST['allow_in_pm'])) ? true : false;						$max_filesize	= request_var('max_filesize', 0);						$max_filesize	= ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize);						$allow_group	= (isset($_POST['allow_group'])) ? true : false;						if ($max_filesize == $config['max_filesize'])						{							$max_filesize = 0;						}						if (!sizeof($allowed_forums))						{							$forum_select = false;						}						$group_ary = array(							'group_name'	=> $group_name,							'cat_id'		=> request_var('special_category', ATTACHMENT_CATEGORY_NONE),							'allow_group'	=> ($allow_group) ? 1 : 0,							'upload_icon'	=> ($upload_icon == 'no_image') ? '' : $upload_icon,							'max_filesize'	=> $max_filesize,							'allowed_forums'=> ($forum_select) ? serialize($allowed_forums) : '',							'allow_in_pm'	=> ($allow_in_pm) ? 1 : 0,						);						if ($action == 'add')						{							$group_ary['download_mode'] = INLINE_LINK;						}						$sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET ';						$sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary);						$sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : '';						$db->sql_query($sql);						if ($action == 'add')						{							$group_id = $db->sql_nextid();						}						add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name);					}					$extension_list = request_var('extensions', array(0));					if ($action == 'edit' && sizeof($extension_list))					{						$sql = 'UPDATE ' . EXTENSIONS_TABLE . "							SET group_id = 0							WHERE group_id = $group_id";						$db->sql_query($sql);					}					if (sizeof($extension_list))					{						$sql = 'UPDATE ' . EXTENSIONS_TABLE . " 							SET group_id = $group_id							WHERE " . $db->sql_in_set('extension_id', $extension_list);						$db->sql_query($sql);					}					$cache->destroy('_extensions');					if (!sizeof($error))					{						$notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)];					}				}				$cat_lang = array(					ATTACHMENT_CATEGORY_NONE		=> $user->lang['NO_FILE_CAT'],					ATTACHMENT_CATEGORY_IMAGE		=> $user->lang['CAT_IMAGES'],					ATTACHMENT_CATEGORY_WM			=> $user->lang['CAT_WM_FILES'],					ATTACHMENT_CATEGORY_RM			=> $user->lang['CAT_RM_FILES'],					ATTACHMENT_CATEGORY_FLASH		=> $user->lang['CAT_FLASH_FILES'],					ATTACHMENT_CATEGORY_QUICKTIME	=> $user->lang['CAT_QUICKTIME_FILES'],				);				$group_id = request_var('g', 0);				$action = (isset($_POST['add'])) ? 'add' : $action;				switch ($action)				{					case 'delete':						if (confirm_box(true))						{							$sql = 'SELECT group_name 								FROM ' . EXTENSION_GROUPS_TABLE . "								WHERE group_id = $group_id";							$result = $db->sql_query($sql);							$group_name = (string) $db->sql_fetchfield('group_name');							$db->sql_freeresult($result);							$sql = 'DELETE 								FROM ' . EXTENSION_GROUPS_TABLE . " 								WHERE group_id = $group_id";							$db->sql_query($sql);							// Set corresponding Extensions to a pending Group							$sql = 'UPDATE ' . EXTENSIONS_TABLE . "								SET group_id = 0								WHERE group_id = $group_id";							$db->sql_query($sql);												add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $group_name);							$cache->destroy('_extensions');							trigger_error($user->lang['EXTENSION_GROUP_DELETED'] . adm_back_link($this->u_action));						}						else						{							confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(								'i'			=> $id,								'mode'		=> $mode,								'group_id'	=> $group_id,								'action'	=> 'delete',							)));						}					break;					case 'edit':						if (!$group_id)						{							trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);						}						$sql = 'SELECT *							FROM ' . EXTENSION_GROUPS_TABLE . "							WHERE group_id = $group_id";						$result = $db->sql_query($sql);						$ext_group_row = $db->sql_fetchrow($result);						$db->sql_freeresult($result);						$forum_ids = (!$ext_group_row['allowed_forums']) ? array() : unserialize(trim($ext_group_row['allowed_forums']));					// no break;					case 'add':						if ($action == 'add')						{							$ext_group_row = array(								'group_name'	=> request_var('group_name', '', true),								'cat_id'		=> 0,								'allow_group'	=> 1,								'allow_in_pm'	=> 1,								'upload_icon'	=> '',								'max_filesize'	=> 0,							);							$forum_ids = array();						}						$extensions = array();						$sql = 'SELECT *							FROM ' . EXTENSIONS_TABLE . "							WHERE group_id = $group_id								OR group_id = 0							ORDER BY extension";						$result = $db->sql_query($sql);						$extensions = $db->sql_fetchrowset($result);						$db->sql_freeresult($result);						if ($ext_group_row['max_filesize'] == 0)						{							$ext_group_row['max_filesize'] = (int) $config['max_filesize'];						}						$size_format = ($ext_group_row['max_filesize'] >= 1048576) ? 'mb' : (($ext_group_row['max_filesize'] >= 1024) ? 'kb' : 'b');						$ext_group_row['max_filesize'] = ($ext_group_row['max_filesize'] >= 1048576) ? round($ext_group_row['max_filesize'] / 1048576 * 100) / 100 : (($ext_group_row['max_filesize'] >= 1024) ? round($ext_group_row['max_filesize'] / 1024 * 100) / 100 : $ext_group_row['max_filesize']);						$img_path = $config['upload_icons_path'];						$filename_list = '';						$no_image_select = false;						$imglist = filelist($phpbb_root_path . $img_path);						if (sizeof($imglist))						{							$imglist = array_values($imglist);							$imglist = $imglist[0];							foreach ($imglist as $key => $img)							{								if (!$ext_group_row['upload_icon'])								{									$no_image_select = true;									$selected = '';								}								else								{									$selected = ($ext_group_row['upload_icon'] == $img) ? ' selected="selected"' : '';								}								if (strlen($img) > 255)								{									continue;								}								$filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . htmlspecialchars($img) . '</option>';							}						}						$i = 0;						$assigned_extensions = '';						foreach ($extensions as $num => $row)						{							if ($row['group_id'] == $group_id && $group_id)							{								$assigned_extensions .= ($i) ? ', ' . $row['extension'] : $row['extension'];								$i++;							}						}						$s_extension_options = '';						foreach ($extensions as $row)						{							$s_extension_options .= '<option' . ((!$row['group_id']) ? ' class="disabled"' : '') . ' value="' . $row['extension_id'] . '"' . (($row['group_id'] == $group_id && $group_id) ? ' selected="selected"' : '') . '>' . $row['extension'] . '</option>';						}						$template->assign_vars(array(							'PHPBB_ROOT_PATH'		=> $phpbb_root_path,							'IMG_PATH'				=> $img_path,							'ACTION'				=> $action,							'GROUP_ID'				=> $group_id,							'GROUP_NAME'			=> $ext_group_row['group_name'],							'ALLOW_GROUP'			=> $ext_group_row['allow_group'],							'ALLOW_IN_PM'			=> $ext_group_row['allow_in_pm'],							'UPLOAD_ICON_SRC'		=> $phpbb_root_path . $img_path . '/' . $ext_group_row['upload_icon'],							'EXTGROUP_FILESIZE'		=> $ext_group_row['max_filesize'],							'ASSIGNED_EXTENSIONS'	=> $assigned_extensions,							'S_CATEGORY_SELECT'			=> $this->category_select('special_category', $group_id, 'category'),							'S_EXT_GROUP_SIZE_OPTIONS'	=> size_select_options($size_format),							'S_EXTENSION_OPTIONS'		=> $s_extension_options,							'S_FILENAME_LIST'			=> $filename_list,							'S_EDIT_GROUP'				=> true,							'S_NO_IMAGE'				=> $no_image_select,							'S_FORUM_IDS'				=> (sizeof($forum_ids)) ? true : false,							'U_EXTENSIONS'		=> append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&amp;mode=extensions"),							'U_BACK'			=> $this->u_action,							'L_LEGEND'			=> $user->lang[strtoupper($action) . '_EXTENSION_GROUP'])						);						$s_forum_id_options = '';						$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id							FROM ' . FORUMS_TABLE . '							ORDER BY left_id ASC';						$result = $db->sql_query($sql);						$right = $cat_right = $padding_inc = 0;						$padding = $forum_list = $holding = '';						$padding_store = array('0' => '');						while ($row = $db->sql_fetchrow($result))						{							if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))							{								// Non-postable forum with no subforums, don't display								continue;							}							if (!$auth->acl_get('f_list', $row['forum_id']))							{								// if the user does not have permissions to list this forum skip								continue;							}							if ($row['left_id'] < $right)							{								$padding .= '&nbsp; &nbsp;';								$padding_store[$row['parent_id']] = $padding;							}							else if ($row['left_id'] > $right + 1)							{								$padding = $padding_store[$row['parent_id']];							}							$right = $row['right_id'];							$selected = (in_array($row['forum_id'], $forum_ids)) ? ' selected="selected"' : '';							if ($row['left_id'] > $cat_right)							{								$holding = '';							}							if ($row['right_id'] - $row['left_id'] > 1)							{								$cat_right = max($cat_right, $row['right_id']);								$holding .= '<option value="' . $row['forum_id'] . '"' . (($row['forum_type'] == FORUM_POST) ? ' class="blue"' : '') . $selected . '>' . $padding . $row['forum_name'] . '</option>';							}							else							{								$s_forum_id_options .= $holding . '<option value="' . $row['forum_id'] . '"' . (($row['forum_type'] == FORUM_POST) ? ' class="blue"' : '') . $selected . '>' . $padding . $row['forum_name'] . '</option>';								$holding = '';							}						}						$db->sql_freeresult($result);						unset($padding_store);						$template->assign_vars(array(							'S_FORUM_ID_OPTIONS'	=> $s_forum_id_options)						);					break;				}				$sql = 'SELECT *					FROM ' . EXTENSION_GROUPS_TABLE . '					ORDER BY allow_group DESC, allow_in_pm DESC, group_name';				$result = $db->sql_query($sql);				$old_allow_group = $old_allow_pm = 1;				while ($row = $db->sql_fetchrow($result))				{					$s_add_spacer = ($old_allow_group != $row['allow_group'] || $old_allow_pm != $row['allow_in_pm']) ? true : false;					$template->assign_block_vars('groups', array(						'S_ADD_SPACER'		=> $s_add_spacer,						'S_ALLOWED_IN_PM'	=> ($row['allow_in_pm']) ? true : false,						'S_GROUP_ALLOWED'	=> ($row['allow_group']) ? true : false,						'U_EDIT'		=> $this->u_action . "&amp;action=edit&amp;g={$row['group_id']}",						'U_DELETE'		=> $this->u_action . "&amp;action=delete&amp;g={$row['group_id']}",						'GROUP_NAME'	=> $row['group_name'],						'CATEGORY'		=> $cat_lang[$row['cat_id']],						)					);					$old_allow_group = $row['allow_group'];					$old_allow_pm = $row['allow_in_pm'];				}				$db->sql_freeresult($result);			break;			case 'orphan':				if ($submit)				{					$delete_files = (isset($_POST['delete'])) ? array_keys(request_var('delete', array('' => 0))) : array();					$add_files = (isset($_POST['add'])) ? array_keys(request_var('add', array('' => 0))) : array();					$post_ids = request_var('post_id', array('' => 0));					if (sizeof($delete_files))					{						$sql = 'SELECT *							FROM ' . ATTACHMENTS_TABLE . '							WHERE ' . $db->sql_in_set('attach_id', $delete_files) . '								AND is_orphan = 1';						$result = $db->sql_query($sql);						$delete_files = array();						while ($row = $db->sql_fetchrow($result))						{							phpbb_unlink($row['physical_filename'], 'file');							if ($row['thumbnail'])							{								phpbb_unlink($row['physical_filename'], 'thumbnail');							}							$delete_files[$row['attach_id']] = $row['real_filename'];						}						$db->sql_freeresult($result);					}					if (sizeof($delete_files))					{						$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '							WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files));						$db->sql_query($sql);						add_log('admin', 'LOG_ATTACH_ORPHAN_DEL', implode(', ', $delete_files));						$notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files));					}					$upload_list = array();					foreach ($add_files as $attach_id)					{						if (!in_array($attach_id, array_keys($delete_files)) && !empty($post_ids[$attach_id]))						{							$upload_list[$attach_id] = $post_ids[$attach_id];						}					}					unset($add_files);					if (sizeof($upload_list))					{						$template->assign_var('S_UPLOADING_FILES', true);						$sql = 'SELECT forum_id, forum_name							FROM ' . FORUMS_TABLE;						$result = $db->sql_query($sql);						$forum_names = array();						while ($row = $db->sql_fetchrow($result))						{							$forum_names[$row['forum_id']] = $row['forum_name'];						}						$db->sql_freeresult($result);						$sql = 'SELECT forum_id, topic_id, post_id, poster_id							FROM ' . POSTS_TABLE . '							WHERE ' . $db->sql_in_set('post_id', $upload_list);						$result = $db->sql_query($sql);						$post_info = array();						while ($row = $db->sql_fetchrow($result))						{							$post_info[$row['post_id']] = $row;						}						$db->sql_freeresult($result);						// Select those attachments we want to change...						$sql = 'SELECT *							FROM ' . ATTACHMENTS_TABLE . '							WHERE ' . $db->sql_in_set('attach_id', array_keys($upload_list)) . '								AND is_orphan = 1';						$result = $db->sql_query($sql);						while ($row = $db->sql_fetchrow($result))						{							$post_row = $post_info[$upload_list[$row['attach_id']]];							$template->assign_block_vars('upload', array(								'FILE_INFO'		=> sprintf($user->lang['UPLOADING_FILE_TO'], $row['real_filename'], $post_row['post_id']),								'S_DENIED'		=> (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? true : false,								'L_DENIED'		=> (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? sprintf($user->lang['UPLOAD_DENIED_FORUM'], $forum_names[$row['forum_id']]) : '')							);							if (!$auth->acl_get('f_attach', $post_row['forum_id']))							{								continue;							}							// Adjust attachment entry							$sql_ary = array(								'in_message'	=> 0,								'is_orphan'		=> 0,								'poster_id'		=> $post_row['poster_id'],								'post_msg_id'	=> $post_row['post_id'],								'topic_id'		=> $post_row['topic_id'],

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -