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

📄 acp_styles.php

📁 这些都是我以前学习是用到的源码
💻 PHP
📖 第 1 页 / 共 5 页
字号:
				// notify the user if the template was not stored in the db before his modification				if (!$theme_info['theme_storedb'])				{					add_log('admin', 'LOG_THEME_EDIT_DETAILS', $theme_info['theme_name']);					$message .= '<br />' . $user->lang['EDIT_THEME_STORED_DB'];				}			}			$cache->destroy('sql', STYLES_THEME_TABLE);			add_log('admin', ($add_custom) ? 'LOG_THEME_EDIT_ADD' : 'LOG_THEME_EDIT', $theme_info['theme_name'], ($add_custom) ? $custom_class : $edit_class);			trigger_error($message . adm_back_link($this->u_action . "&amp;action=edit&amp;id=$theme_id&amp;css_class=$edit_class&amp;showcss=$show_css&amp;text_rows=$text_rows"));		}		unset($matches);		$s_hidden_fields['css_class'] = $edit_class;		$template->assign_vars(array(			'S_HIDDEN_FIELDS'	=> build_hidden_fields($s_hidden_fields),			'U_SWATCH'			=> append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=acp_theme') . '&amp;name=',			'UA_SWATCH'			=> append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=acp_theme', false) . '&name=',			'CSS_DATA'			=> htmlspecialchars($css_data))		);	}	/**	* Edit imagesets	*	* @param int $imageset_id specifies which imageset is being edited	*/	function edit_imageset($imageset_id)	{		global $db, $user, $phpbb_root_path, $cache, $template;		$this->page_title = 'EDIT_IMAGESET';		$update		= (isset($_POST['update'])) ? true : false;		$imgname	= request_var('imgname', '');		$imgpath	= request_var('imgpath', '');		$imgsize	= request_var('imgsize', false);		$imgwidth	= request_var('imgwidth', 0);		$imgname	= preg_replace('#[^a-z0-9\-+_]#i', '', $imgname);		$imgpath	= str_replace('..', '.', $imgpath);		if ($imageset_id)		{			$sql_select = ($imgname) ? ", $imgname" : '';			$sql = "SELECT imageset_path, imageset_name, imageset_copyright$sql_select				FROM " . STYLES_IMAGESET_TABLE . "				WHERE imageset_id = $imageset_id";			$result = $db->sql_query($sql);			$imageset_row = $db->sql_fetchrow($result);			$db->sql_freeresult($result);			if (!$imageset_row)			{				trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING);			}			extract($imageset_row);			// Check to see whether the selected image exists in the table			$valid_name = ($update) ? false : true;			foreach ($this->imageset_keys as $category => $img_ary)			{				if (in_array($imgname, $img_ary))				{					$valid_name = true;					break;				}			}			if ($update && $imgpath)			{				if ($valid_name)				{					// If imgwidth and imgheight are non-zero grab the actual size					// from the image itself ... we ignore width settings for the poll center					// image					$imgwidth = $imgheight = '';					if ($imgsize)					{						list($imgwidth, $imgheight) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath");						$imgheight = '*' . $imgheight;						$imgwidth = ($imgname != 'poll_center') ? '*' . $imgwidth : '';					}					$imgpath = preg_replace('/^([^\/]+\/)/', '{LANG}/', $imgpath) . $imgheight . $imgwidth;					$sql = 'UPDATE ' . STYLES_IMAGESET_TABLE . "						SET $imgname = '" . $db->sql_escape($imgpath) . "'						WHERE imageset_id = $imageset_id";					$db->sql_query($sql);					$cache->destroy('sql', STYLES_IMAGESET_TABLE);					add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name);					$template->assign_var('SUCCESS', true);					$$imgname = $imgpath;				}			}		}		// Generate list of image options		$img_options = '';		foreach ($this->imageset_keys as $category => $img_ary)		{			$template->assign_block_vars('category', array(				'NAME'			=> $user->lang['IMG_CAT_' . strtoupper($category)]			));			foreach ($img_ary as $img)			{				$template->assign_block_vars('category.images', array(					'SELECTED'			=> ($img == $imgname),					'VALUE'				=> $img,					'TEXT'				=> (($category == 'custom') ? $img : $user->lang['IMG_' . strtoupper($img)])				));			}		}		// TODO		// Check whether localised buttons exist in admins language first		// Clean up this code		$imglang = '';		$imagesetlist = array('nolang' => array(), 'lang' => array());		$dir = "{$phpbb_root_path}styles/$imageset_path/imageset";		$dp = opendir($dir);		while (($file = readdir($dp)) !== false)		{			if (!is_file($dir . '/' . $file) && !is_link($dir . '/' . $file) && $file[0] != '.' && strtoupper($file) != 'CVS' && !sizeof($imagesetlist['lang']))			{				$dp2 = opendir("$dir/$file");				while (($file2 = readdir($dp2)) !== false)				{					$imglang = $file;					if (preg_match('#\.(?:gif|jpg|png)$#', $file2))					{						$imagesetlist['lang'][] = "$file/$file2";					}				}				closedir($dp2);			}			else if (preg_match('#\.(?:gif|jpg|png)$#', $file))			{				$imagesetlist['nolang'][] = $file;			}		}		closedir($dp);		// Make sure the list of possible images is sorted alphabetically		sort($imagesetlist['nolang']);		sort($imagesetlist['lang']);		$imagesetlist_options = '';		foreach ($imagesetlist as $type => $img_ary)		{			$template->assign_block_vars('imagesetlist', array(				'TYPE'	=> ($type == 'lang')			));			foreach ($img_ary as $img)			{				$imgtext = preg_replace('/^([^\/]+\/)/', '', $img);				$selected = (!empty($imgname) && strpos($$imgname, $imgtext) !== false);				if ($selected)				{					$template->assign_var('IMAGE_SELECT', true);				}				$template->assign_block_vars('imagesetlist.images', array(					'SELECTED'			=> $selected,					'TEXT'				=> $imgtext,					'VALUE'				=> htmlspecialchars($img)				));			}		}		$imgsize_bool = (!empty($imgname) && ($imgsize || preg_match('#\*\d+#', $$imgname))) ? true : false;		$img_info = (!empty($imgname)) ? explode('*', $$imgname) : array();		$template->assign_vars(array(			'S_EDIT_IMAGESET'	=> true,			'L_TITLE'			=> $user->lang[$this->page_title],			'L_EXPLAIN'			=> $user->lang[$this->page_title . '_EXPLAIN'],			'IMAGE_OPTIONS'		=> $img_options,			'IMAGELIST_OPTIONS'	=> $imagesetlist_options,			'IMAGE_SIZE'		=> $imgsize_bool,			'IMAGE_REQUEST'		=> (!empty($img_info[0])) ? '../styles/' . $imageset_path . '/imageset/' . str_replace('{LANG}', $imglang, $img_info[0]) : '',			'U_ACTION'			=> $this->u_action . "&amp;action=edit&amp;id=$imageset_id",			'U_BACK'			=> $this->u_action,			'NAME'				=> $imageset_name,			'ERROR'				=> !$valid_name		));	}	/**	* Remove style/template/theme/imageset	*/	function remove($mode, $style_id)	{		global $db, $template, $user, $phpbb_root_path, $cache, $config;		$new_id = request_var('new_id', 0);		$update = (isset($_POST['update'])) ? true : false;		switch ($mode)		{			case 'style':				$sql_from = STYLES_TABLE;				$sql_select = 'style_name';			break;			case 'template':				$sql_from = STYLES_TEMPLATE_TABLE;				$sql_select = 'template_name, template_path, template_storedb';			break;			case 'theme':				$sql_from = STYLES_THEME_TABLE;				$sql_select = 'theme_name, theme_path, theme_storedb';			break;			case 'imageset':				$sql_from = STYLES_IMAGESET_TABLE;				$sql_select = 'imageset_name, imageset_path';			break;		}		$l_prefix = strtoupper($mode);		$sql = "SELECT $sql_select			FROM $sql_from			WHERE {$mode}_id = $style_id";		$result = $db->sql_query($sql);		$style_row = $db->sql_fetchrow($result);		$db->sql_freeresult($result);		if (!$style_row)		{			trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING);		}		$sql = "SELECT {$mode}_id, {$mode}_name			FROM $sql_from			WHERE {$mode}_id <> $style_id			ORDER BY {$mode}_name ASC";		$result = $db->sql_query($sql);		$s_options = '';		if ($row = $db->sql_fetchrow($result))		{			do			{				$s_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>';			}			while ($row = $db->sql_fetchrow($result));		}		else		{			trigger_error($user->lang['ONLY_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING);		}		$db->sql_freeresult($result);		if ($update)		{			$sql = "DELETE FROM $sql_from				WHERE {$mode}_id = $style_id";			$db->sql_query($sql);			if ($mode == 'style')			{				$sql = 'UPDATE ' . USERS_TABLE . "					SET user_style = $new_id					WHERE user_style = $style_id";				$db->sql_query($sql);				$sql = 'UPDATE ' . FORUMS_TABLE . "					SET forum_style = $new_id					WHERE forum_style = $style_id";				$db->sql_query($sql);				if ($style_id == $config['default_style'])				{					set_config('default_style', $new_id);				}			}			else			{				$sql = 'UPDATE ' . STYLES_TABLE . "					SET {$mode}_id = $new_id					WHERE {$mode}_id = $style_id";				$db->sql_query($sql);			}			$cache->destroy('sql', STYLES_TABLE);			add_log('admin', 'LOG_' . $l_prefix . '_DELETE', $style_row[$mode . '_name']);			$message = ($mode != 'style') ? $l_prefix . '_DELETED_FS' : $l_prefix . '_DELETED';			trigger_error($user->lang[$message] . adm_back_link($this->u_action));		}		$this->page_title = 'DELETE_' . $l_prefix;		$template->assign_vars(array(			'S_DELETE'			=> true,			'S_REPLACE_OPTIONS'	=> $s_options,			'L_TITLE'			=> $user->lang[$this->page_title],			'L_EXPLAIN'			=> $user->lang[$this->page_title . '_EXPLAIN'],			'L_NAME'			=> $user->lang[$l_prefix . '_NAME'],			'L_REPLACE'			=> $user->lang['REPLACE_' . $l_prefix],			'L_REPLACE_EXPLAIN'	=> $user->lang['REPLACE_' . $l_prefix . '_EXPLAIN'],			'U_ACTION'		=> $this->u_action . "&amp;action=delete&amp;id=$style_id",			'U_BACK'		=> $this->u_action,			'NAME'			=> $style_row[$mode . '_name'],			)		);	}	/**	* Export style or style elements	*/	function export($mode, $style_id)	{		global $db, $template, $user, $phpbb_root_path, $cache, $phpEx, $config;		$update = (isset($_POST['update'])) ? true : false;		$inc_template = request_var('inc_template', 0);		$inc_theme = request_var('inc_theme', 0);		$inc_imageset = request_var('inc_imageset', 0);		$store = request_var('store', 0);		$format = request_var('format', '');		$error = array();		$methods = array('tar');		$available_methods = array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib');		foreach ($available_methods as $type => $module)		{			if (!@extension_loaded($module))			{				continue;			}			$methods[] = $type;		}		if (!in_array($format, $methods))		{			$format = 'tar';		}		switch ($mode)		{			case 'style':				if ($update && ($inc_template + $inc_theme + $inc_imageset) < 1)				{					$error[] = $user->lang['STYLE_ERR_MORE_ELEMENTS'];				}				$name = 'style_name';				$sql_select = 's.style_id, s.style_name, s.style_copyright';				$sql_select .= ($inc_template) ? ', t.*' : ', t.template_name';				$sql_select .= ($inc_theme) ? ', c.*' : ', c.theme_name';				$sql_select .= ($inc_imageset) ? ', i.*' : ', i.imageset_name';				$sql_from = STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . ' i';				$sql_where = "s.style_id = $style_id AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id";				$l_prefix = 'STYLE';			break;			case 'template':				$name = 'template_name';				$sql_select = '*';				$sql_from = STYLES_TEMPLATE_TABLE;				$sql_where = "template_id = $style_id";				$l_prefix = 'TEMPLATE';			break;			case 'theme':				$name = 'theme_name';				$sql_select = '*';				$sql_from = STYLES_THEME_TABLE;				$sql_where = "theme_id = $style_id";				$l_prefix = 'THEME';			break;			case 'imageset':				$name = 'imageset_name';				$sql_select = '*';				$sql_from = STYLES_IMAGESET_TABLE;				$sql_where = "imageset_id = $style_id";				$l_prefix = 'IMAGESET';			break;		}		if ($update && !sizeof($error))		{			$sql = "SELECT $sql_select				FROM $sql_from				WHERE $sql_where";			$result = $db->sql_query($sql);			$style_row = $db->sql_fetchrow($result);			$db->sql_freeresult($result);			if (!$style_row)			{				trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING);			}			$var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_storedb', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright', 'theme_storedb', 'theme_mtime', 'theme_data', 'imageset_id', 'imageset_name', 'imageset_path', 'imageset_copyright');			foreach ($var_ary as $var)			{				if (!isset($style_row[$var]))				{					$style_row[$var] = '';				}

⌨️ 快捷键说明

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